react router in saga

Solutions on MaxInterview for react router in saga by the best coders in the world

showing results for - "react router in saga"
Amaris
12 Jun 2016
1/** history.js ****/
2import {createBrowserHistory} from 'history'
3
4export default createBrowserHistory({your_config_here})
5
6/** saga.js ***/
7import {... call} from 'redux-saga/effects'
8import history from './history'
9export default function* your_root_saga(){
10  ...access history here or in your sub sagas...
11  yield call([history, history.push], 'your_object_path')
12}
13
14
15/** index.js ****/
16import history from './history'
17import {Router, ...} from 'react-router-dom'
18import your_root_saga from './sagas'
19import {createSagaMiddleware} from 'redux-saga'
20
21const sagaMiddleware = createSagaMiddleware()
22...config_your_store_here...
23sagaMiddleware.run(your_root_saga)
24
25
26render( <Router history = {history}> ... </Router>
27, document.getElementById('elementId'))
28