Created
January 19, 2018 04:53
-
-
Save ryanjyost/52c5d23e308796a4c292beb9212e8a9d to your computer and use it in GitHub Desktop.
The index.js for Dog Saga - Redux-Saga Beginner Tutorial
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 "./index.css"; | |
| import App from "./App"; | |
| import registerServiceWorker from "./registerServiceWorker"; | |
| import { createStore, applyMiddleware, compose } from "redux"; | |
| import createSagaMiddleware from "redux-saga"; | |
| import { Provider } from "react-redux"; | |
| import { reducer } from "./redux"; | |
| import { watcherSaga } from "./sagas"; | |
| // create the saga middleware | |
| const sagaMiddleware = createSagaMiddleware(); | |
| // dev tools middleware | |
| const reduxDevTools = | |
| window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(); | |
| // create a redux store with our reducer above and middleware | |
| let store = createStore( | |
| reducer, | |
| compose(applyMiddleware(sagaMiddleware), reduxDevTools) | |
| ); | |
| // run the saga | |
| sagaMiddleware.run(watcherSaga); | |
| ReactDOM.render( | |
| <Provider store={store}> | |
| <App /> | |
| </Provider>, | |
| document.getElementById("root") | |
| ); | |
| registerServiceWorker(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to official doc, Advanced store setup should be as followed: