在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 })
    }
  })
}

posted @   徐同保  阅读(41)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示