我在使用 Jsx 时遇到了这个奇怪的问题,当我想打印我的响应项目时它可以工作,并且我看到它在那里并持有一个值,但是当我尝试将它分配为状态时它说它是未定义的
getUserAsync(this.state.Email)
//Console.log display the data no problem!! typeof String.
.then(resp =>{ console.log(resp.Hub.Data)}) //Works!!!
.then((resp => {
this.setState({
//Below I get ERROR Unhandled Rejection (TypeError): Cannot read property 'Hub' of undefined
CSQReadings: resp.Hub.Data, //ERRPR???
});
}))
知道为什么要这样做吗?