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
| git branch --merged | grep -v main | xargs -n 1 git branch -D |
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
| const Daruma = () => { | |
| const { state, } = React.useContext(DarumaContext); | |
| switch (state) { | |
| case WishState.PENDING: | |
| return <DarumaPending />; | |
| case WishState.STARTED: | |
| return <DarumaStarted />; | |
| default: | |
| return <DarumaFulfilled />; |
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
| type DarumaContextType = { | |
| state: WishState, | |
| dispatch: React.Dispatch<any>, | |
| }; | |
| const DarumaContext = React.createContext({} as DarumaContextType); | |
| const reducer = (state: WishState, action: any) => { | |
| switch (action.type) { | |
| case Actions.PAINT: |
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
| enum Actions { | |
| PAINT, | |
| UNDO, | |
| } | |
| const reducer = (state: WishState, action: any) => { | |
| switch (action.type) { | |
| case Actions.PAINT: | |
| return forward(state); | |
| case Actions.UNDO: |
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
| const App = () => { | |
| const [state, setState] = React.useState(WishState.PENDING); | |
| return ( | |
| <> | |
| <Daruma | |
| state={state} | |
| /> | |
| <Buttons | |
| paint={() => setState(forward(state))} |
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
| type DarumaProps = { | |
| state: WishState, | |
| }; | |
| const Daruma = ({ | |
| state, | |
| }: DarumaProps) => { | |
| switch (state) { | |
| case WishState.PENDING: | |
| return <DarumaPending />; |
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
| enum WishState { | |
| PENDING = 1, | |
| STARTED = 2, | |
| FULFILLED = 3, | |
| }; | |
| const forward = (state: WishState) => { | |
| switch (state) { | |
| case WishState.PENDING: | |
| return WishState.STARTED; |
NewerOlder