Skip to content

Instantly share code, notes, and snippets.

@01Clarian
Created December 10, 2019 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 01Clarian/f61dcfd9db0be4303f0346cda727a8e6 to your computer and use it in GitHub Desktop.
Save 01Clarian/f61dcfd9db0be4303f0346cda727a8e6 to your computer and use it in GitHub Desktop.
Wrapping the Products Provider around the Application
import React from 'react'
import { render } from 'react-dom'
import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import { createLogger } from 'redux-logger'
import thunk from 'redux-thunk'
import reducer from './reducers'
import { getAllProducts } from './actions'
import App from './containers/App'
import ProductsProvider from './provider/products.provider'
const middleware = [thunk];
if (process.env.NODE_ENV !== 'production') {
middleware.push(createLogger());
}
const store = createStore(
reducer,
applyMiddleware(...middleware)
)
store.dispatch(getAllProducts())
render(
<ProductsProvider>
<Provider store={store}>
<App />
</Provider>
</ProductsProvider>,
document.getElementById('root')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment