📜  saga 中的 react-router - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:44.956000             🧑  作者: Mango

代码示例1
/** 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(  ... 
, document.getElementById('elementId'))