Last active
December 21, 2018 16:44
-
-
Save jamesseanwright/9f755e788bfdcb5ebf2fdefbd7ef0634 to your computer and use it in GitHub Desktop.
Roll Your Own Redux Provider
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
| export const Provider: React.FC<ProviderProps> = ({ | |
| reducer, | |
| children, | |
| }) => { | |
| const [state, dispatch] = React.useReducer(reducer, defaultState); | |
| return ( | |
| <StateContext.Provider value={{ | |
| state, | |
| dispatch, | |
| }}> | |
| {children} | |
| </StateContext.Provider> | |
| ); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment