Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript react redux不重新提交,除非刷新_Javascript_Reactjs_Ecmascript 6_Redux - Fatal编程技术网

Javascript react redux不重新提交,除非刷新

Javascript react redux不重新提交,除非刷新,javascript,reactjs,ecmascript-6,redux,Javascript,Reactjs,Ecmascript 6,Redux,我花了好几个小时不明白,如果我登录并且没有刷新我的应用程序,为什么redux中没有状态变化 我的行动 export function applyAd(id) { return (dispatch, getState, { emit }) => { dispatch({ type: APPLYING_AD }) axios .put(`/ad/apply`, { id }) .then(res => { if (res.st

我花了好几个小时不明白,如果我登录并且没有刷新我的应用程序,为什么redux中没有状态变化

我的行动

export function applyAd(id) {
  return (dispatch, getState, { emit }) => {
    dispatch({ type: APPLYING_AD })

    axios
      .put(`/ad/apply`, { id })
      .then(res => {
        if (res.status === 200 && res.data.status === 1) {
          dispatch({
            type: APPLY_AD,
            payload: res.data.data
          })

        }
      })
      .catch(res => {
        console.log('res',res)
      })
  }
}
我的减速机

//...
case APPLYING_AD:
  return {
    ...state,
    loading_apply_ad: true
}
case APPLY_AD:
  return {
    ...state,
    ad: {
      ...state.ad,
      status: action.payload.ad.status,
      loading_apply_ad: false
   }
}
//...

我病得很厉害,这个错误让我被困了两天多,我甚至不知道为什么它不能重新启动(登录后刷新后它会工作)。我比较了登录、登录和刷新后的状态,状态是相同的。

其中是
applyAd
调用自?plz提供组件代码。