redux redx-saga router code example

Example: react-router in saga

/** history.js ****/
import {createBrowserHistory} from 'history'

export default createBrowserHistory({your_config_here})

/** saga.js ***/
import {... call} from 'redux-saga/effects'
import history from './history'
export default function* your_root_saga(){
  ...access history here or in your sub sagas...
  yield call([history, history.push], 'your_object_path')
}


/** index.js ****/
import history from './history'
import {Router, ...} from 'react-router-dom'
import your_root_saga from './sagas'
import {createSagaMiddleware} from 'redux-saga'

const sagaMiddleware = createSagaMiddleware()
...config_your_store_here...
sagaMiddleware.run(your_root_saga)


render( <Router history = {history}> ... </Router>
, document.getElementById('elementId'))