Created
March 13, 2018 01:47
-
-
Save bowheart/9700fe192988b055079b5e7973f0a103 to your computer and use it in GitHub Desktop.
Provide and consume a Redux store with React Zedux
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 { createContext } from 'react-zedux' | |
import { createStore } from 'redux' | |
import rootReducer from './reducers' | |
const store = createStore(rootReducer) | |
const Context = createContext(store) | |
const App = () => ( | |
<Context.Provider> | |
<HelloWorld /> | |
</Context.Provider> | |
) | |
const HelloWorld = () => ( | |
<Context.Consumer> | |
{store => 'hello ' + store.getState()} | |
</Context.Consumer> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment