Last active
April 9, 2018 07:50
-
-
Save dbismut/19be5f53d782bdf64e2be4b21a6c8901 to your computer and use it in GitHub Desktop.
Part 1 - Wrapping the App in store and router providers
This file contains hidden or 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 ReactDOM from 'react-dom'; | |
| import { Provider } from 'react-redux'; | |
| import { RouterProvider } from 'react-router5'; | |
| import configureStore from './_redux/store'; | |
| import createRouter from './_router/router'; | |
| import dataMiddleware from './_router/dataMiddleware'; | |
| import routes from './_router/routes'; | |
| import registerServiceWorker from './registerServiceWorker'; | |
| import App from './App'; | |
| import './index.css'; | |
| const router = createRouter(routes); | |
| const store = configureStore(router); | |
| router.setDependency('store', store); | |
| router.useMiddleware(dataMiddleware(routes)); | |
| const wrappedApp = ( | |
| <Provider store={store}> | |
| <RouterProvider router={router}> | |
| <App /> | |
| </RouterProvider> | |
| </Provider> | |
| ); | |
| router.start((err, state) => { | |
| ReactDOM.render(wrappedApp, document.getElementById('root')); | |
| }); | |
| registerServiceWorker(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment