【发布时间】:2020-06-17 08:13:34
【问题描述】:
我有一个使用 Saga 和 Redux Store 的项目,这是项目引导方法:
import { createStore, applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
import { fork } from 'redux-saga/effects';
...
const bootstrap = async () => {
const configuration = await config.env();
init(configuration);
const rootReducer = combineReducers({
...reducers,
})
function* rootSaga() {
yield sagas.map(saga => fork(saga))
}
const sagaMiddleware = createSagaMiddleware();
const store = createStore(rootReducer, applyMiddleware(sagaMiddleware));
const App = (): Element<*> => (
<Provider store={store}>
<div>
<WorstProjectInMyLife />
</div>
</Provider>
);
sagaMiddleware.run(rootSaga);
ReactDOM.render(<App />, document.getElementById('app'));
};
bootstrap();
这就是我们向 props 发送状态的地方:
import { createSelector } from 'reselect';
const selectIsFetching = createSelector(
parentSelector,
(parentState: StateRecord = new StateRecord()) => parentState.isFetching
);
const mapStateToProps = (state: StateType) => ({
isFetching: selectIsFetching(state)
});
const mapDispatchToProps = {
...actions
};
export default connect(mapStateToProps, mapDispatchToProps)(WorstProjectInMyLife);
但是商店总是空着,所以我担心这没有正确连接。各位大佬能看一下,是不是我漏了什么?我真的已经为此苦苦挣扎了几天并且变得精神恍惚,因为不知道为什么这不起作用。感谢您的帮助
【问题讨论】:
标签: reactjs redux react-redux redux-saga