Last active
October 16, 2020 03:50
-
-
Save BrianJenney/68fe9fa08f1fae42bdc357554d0b3053 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
import React from 'react' | |
import { | |
Provider, | |
createStoreHook, | |
createDispatchHook, | |
createSelectorHook | |
} from 'react-redux' | |
const MyContext = React.createContext(null) | |
const MyOtherContext = React.createContext(null) | |
// Export your custom hooks if you wish to use them in other files. | |
export const useStore = createStoreHook(MyContext) | |
export const useDispatch = createDispatchHook(MyContext) | |
export const useSelector = createSelectorHook(MyContext) | |
export const useOtherStore = createStoreHook(MyContext) | |
export const useOtherDispatch = createDispatchHook(MyContext) | |
export const useOtherSelector = createSelectorHook(MyContext) | |
const myStore = createStore(rootReducer) | |
const myOtherStore = createStore(rootReducer) | |
export function MyProvider({ children }) { | |
return ( | |
<Provider context={MyContext} store={myStore}> | |
<Provider context={OtherContext} store={myOtherStore}> | |
{children} | |
</Provider> | |
</Provider> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment