Last active
August 14, 2020 02:12
-
-
Save naush/771e2f8e213ceed9f3d54dee8a12ee77 to your computer and use it in GitHub Desktop.
This file contains 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
enum Actions { | |
PAINT, | |
UNDO, | |
} | |
const reducer = (state: WishState, action: any) => { | |
switch (action.type) { | |
case Actions.PAINT: | |
return forward(state); | |
case Actions.UNDO: | |
return backward(state); | |
default: | |
throw new Error(); | |
} | |
}; | |
const App = () => { | |
const [state, dispatch] = React.useReducer(reducer, WishState.PENDING); | |
return ( | |
<> | |
<Daruma | |
state={state} | |
/> | |
<Buttons | |
dispatch={dispatch} | |
/> | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment