Skip to content

Instantly share code, notes, and snippets.

@ilonacodes
Created December 9, 2018 16:33
Show Gist options
  • Save ilonacodes/8ccaa5a639263d6458e6b3c0a80aa915 to your computer and use it in GitHub Desktop.
Save ilonacodes/8ccaa5a639263d6458e6b3c0a80aa915 to your computer and use it in GitHub Desktop.
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