在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 @ 2021-07-09 16:40  徐同保  阅读(40)  评论(0编辑  收藏  举报