繁体   English   中英

redux saga无法读取未定义的属性getState

[英]redux saga cannot read property getState of undefined

我正在尝试使用saga中间件和异步操作以及react-router-redux和选择器来建立一个React Redux存储。

对于某些sagamiddleware,无法读取未定义的属性getState。 我不知道为什么

我的顶级目录结构是:

./src/app.js
./src/sagas/index.js and imported sagas into this file
./src/Containers/App/actions.js constants.js appReducer.js selectors.js
./src/Containers/App/toplevelcomponenthere

app.js

import sagas from './sagas';
import createReducer from './reducers.js';

const sagaMiddleware = createSagaMiddleware();
const createStoreWithMiddleware = applyMiddleware(reduxRouterMiddleware,
sagaMiddleware(...sagas))(createStore);

const store = createStoreWithMiddleware(createReducer);
const reduxRouterMiddleware = syncHistoryWithStore(browserHistory)

//add selectors and history
import { selectLocationState } from './Containers/App/selectors';
const history = syncHistoryWithStore(browserHistory, store, {
  selectLocationState: selectLocationState(),
});

class Base extends Component {
  render() {
    return (
    <Provider store={store}>
    {children}
    </Provider>
    )
  }
}

您错误地应用了传奇中间件。 看一下示例 sagaMiddlewate不带任何参数。

创建商店后,您必须将root saga传递给store.runSaga函数,例如here 这就是根传奇-单个功能,例如, fork您要使用的其他sagas。 我觉得你的sagas进口./sagas不是一个单一的功能,因为您已经应用的扩展操作它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM