在actionCreator中使用getState,数据格式是immutable


const setAuth = () => (dispatch, getState) => {
  const router = getState().getIn(['light', 'router']).toJS()
  Api.light.testAuthSearch().then((res) => {
    if (res.state === 1) {
      const newRouter = formatAuthData({ router: router, authData: res.data })
      console.log(newRouter)
      dispatch({ type: 'SET_LIGHT_STATE', key: ['router'], value: newRouter })
    }
  })
}

原文地址:https://www.cnblogs.com/xutongbao/p/15264335.html