redux动作创建者 - >派遣并没有从thunk中解雇

时间:2016-06-06 16:08:35

标签: reactjs redux redux-thunk

主题行非常清楚地总结了这个问题。

尝试将项目发布到DB,然后从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;

0 个答案:

没有答案