Dva: 请教effect中读取state的值的问题

Created on 31 Jul 2017  ·  4Comments  ·  Source: dvajs/dva

state:{
  user: {username: '1'}
},
subscriptions: {
  setup({dispatch}) {
    dispatch({type: 'getState'});
  },
},
effects: {
  *getState({}, {call, put, select}) {
    const user = yield select(state=>state.user);
    ...
  },
},

取得的user值是undefined。
不知道哪里出了问题,请大神指点,谢谢!
dva版本:1.2.1

question

Most helpful comment

yield select(state => state.main.user); 那得这样取,试着理解下 namespace 的含义。

All 4 comments

namespace 配了吗?

namespace: 'main',

yield select(state => state.main.user); 那得这样取,试着理解下 namespace 的含义。

明白了,可以取到了,谢谢!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sorrycc picture sorrycc  ·  3Comments

MiaoXingGua picture MiaoXingGua  ·  3Comments

ufohjl picture ufohjl  ·  3Comments

pengfeiWang picture pengfeiWang  ·  3Comments

not3 picture not3  ·  3Comments