当我尝试将saga集成到react-native应用程序中时,出现以下错误:
这是商店文件:
import { createStore, combineReducers, compose, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension'
import placeReducer from './reducers/placeReducer';
import createSagaMiddleware from "redux-saga";
import { apiSaga } from "./sagas/api-saga";
const storeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const initialiseSagaMiddleware = createSagaMiddleware();
const rootReducer = combineReducers({
places: placeReducer
});
const configureStore = () => {
return createStore(
rootReducer,
storeEnhancers(applyMiddleware(initialiseSagaMiddleware)))
}
initialiseSagaMiddleware.run(apiSaga);
export default configureStore;
预先感谢
科比
答案 0 :(得分:1)
尝试删除增强子
const configureStore = () => {
return createStore(
rootReducer,
applyMiddleware(initialiseSagaMiddleware))
}
答案 1 :(得分:0)
我认为您需要将默认/初始状态传递到createStore
的第二个参数中,然后将initialiseSagaMiddleware.run(apiSaga);
移动到函数内部。
const configureStore = () => {
return createStore(
rootReducer,
{},
storeEnhancers(applyMiddleware(initialiseSagaMiddleware)));
initialiseSagaMiddleware.run(apiSaga);
}