Skip to content

Instantly share code, notes, and snippets.

@bowheart
Created March 13, 2018 01:47
Show Gist options
  • Save bowheart/9700fe192988b055079b5e7973f0a103 to your computer and use it in GitHub Desktop.
Save bowheart/9700fe192988b055079b5e7973f0a103 to your computer and use it in GitHub Desktop.
Provide and consume a Redux store with React Zedux
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