Created
March 6, 2022 07:42
-
-
Save mohsentaleb/aee0286bca1b4ebf9a23991234aa3712 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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