Skip to content

Instantly share code, notes, and snippets.

@mohsentaleb
Created March 6, 2022 07:42
Show Gist options
  • Save mohsentaleb/aee0286bca1b4ebf9a23991234aa3712 to your computer and use it in GitHub Desktop.
Save mohsentaleb/aee0286bca1b4ebf9a23991234aa3712 to your computer and use it in GitHub Desktop.
import type { Action } from "./actions";
export const initialState = {
content: "Hello World",
background: "#ffcc00"
};
export type Store = typeof initialState;
export const reducer = (state: Store, action: Action) => {
switch (action.type) {
case "SET_BACKGROUND_COLOR":
const background = action.payload.background
return { ...state, background };
case "SET_CONTENT":
const content = action.payload.content;
return { ...state, content };
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment