react-redux-router不会使用调度事件从saga导航。中间件已安装

时间:2017-01-27 15:50:39

标签: reactjs redux react-router saga

我们已经安装了创建商店的中间件层

const sagaMiddleware = sagaMiddlewareFactory();
const routerMiddlewareInstance = routerMiddleware(browserHistory);
const logger = createLogger();
const enhancer = composeWithDevTools(
  // logger middleware needs to be last if you do not want all the logs of previous middleware
  applyMiddleware(sagaMiddleware, routerMiddlewareInstance, logger),
  persistState(
    window.location.href.match(
      /[?&]debug_session=([^&#]+)\b/
    )
  )
);

export default function configureStore(initialState: any) {
  const store = createStore(rootReducer, initialState, enhancer);
  sagaMiddleware.run(rootSaga);
  if (module.hot) {
    module.hot.accept("../reducers", () =>
      store.replaceReducer(require<any>("../reducers").default)
    );
  }

  return store;
}

当我们发送导航事件时:

  const nextPage: NavPage = newNav.pages[toIndex];
  const foo = push(nextPage.url);
  yield put(foo);

应用程序无法导航。

有人对此有何想法?我们没有正确实例化导航中间件吗?由于需要添加开发工具,它与documentation类似,但不完全一样。

1 个答案:

答案 0 :(得分:0)

不确定sagaMiddlewareFactory函数返回了什么,但您是否尝试过使用createSagaMiddleware来创建中间件?也许这会有所帮助吗?

createSagaMiddleware