主题行非常清楚地总结了这个问题。
尝试将项目发布到数据库,然后从 POST 请求中检索新集合。
export function addEntry(props, id, func) {
console.log("Add fn fired")
return dispatch => {
console.log('Dispatch fired')
return makeStaffEntry('post', id, props)
.then(response => {
console.log(response, "RESPONSE")
func()
dispatch(receiveEntry(response.data))
})
}
}
第一个控制台日志会触发,但其余的不会。我无法测试 makeStaffEntry,因为我无法获取“调度已触发”日志。
存储配置
export default function configureStore(initialState, history) {
const middleware = [thunk, promiseMiddleware, routerMiddleware(history)];
if (__DEVCLIENT__) {
middleware.push(createLogger());
}
const store = createStore(rootReducer, initialState, compose(
applyMiddleware(...middleware),
typeof window === 'object' && typeof window.devToolsExtension !== 'undefined' ? window.devToolsExtension() : f => f
));
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('reducers', () => {
const nextReducer = require('reducers');
store.replaceReducer(nextReducer);
});
}
return store;