这是我的商店:
export default function configureStore(preloadedState) {
const sagaMiddleware = createSagaMiddleware();
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const composedEnhancers = composeEnhancers(applyMiddleware(sagaMiddleware));
const store = createStore(rootReducer, preloadedState, composedEnhancers);
sagaMiddleware.run(rootSaga);
return store;
}
这是我的axios实例:
...
import store from "../store/index";
...
myAxios.interceptors.request.use(function (config) {
store().dispatch({ type: LOADER, payload: { showLoader: true } });
console.log("request", store().getState())
return config;
}
看起来像到减速器上了:
...
case LOADER:
console.log("{ ...state, ...payload }", { ...state, ...payload }) // payload is correct
return { ...state, ...payload };
...
但是它不会更新状态