Skip to content

Instantly share code, notes, and snippets.

@jamesseanwright
Last active December 21, 2018 16:44
Show Gist options
  • Select an option

  • Save jamesseanwright/9f755e788bfdcb5ebf2fdefbd7ef0634 to your computer and use it in GitHub Desktop.

Select an option

Save jamesseanwright/9f755e788bfdcb5ebf2fdefbd7ef0634 to your computer and use it in GitHub Desktop.
Roll Your Own Redux Provider
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