Created
December 9, 2018 16:33
-
-
Save ilonacodes/8ccaa5a639263d6458e6b3c0a80aa915 to your computer and use it in GitHub Desktop.
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 ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
import {userReducer} from './reducer'; | |
import {applyMiddleware, combineReducers, createStore} from 'redux'; | |
import createSagaMiddleware from 'redux-saga'; | |
import {Provider} from 'react-redux'; | |
import {watchLoadUserData} from './sagas'; | |
// initializing saga middleware for the store | |
const sagaMiddleware = createSagaMiddleware(); | |
// creating the store with our reducer | |
const store = createStore(combineReducers({ | |
user: userReducer | |
}), applyMiddleware(sagaMiddleware)); | |
// triggering watchLoadUserData when there is a LOAD_USER_DATA | |
sagaMiddleware.run(watchLoadUserData); | |
// wrapping the App in a Provider to work with React and Redux | |
ReactDOM.render( | |
<Provider store={store}> | |
<App/> | |
</Provider>, | |
document.getElementById('root') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment