【发布时间】:2018-06-27 09:43:08
【问题描述】:
class Signup extends React.Component {
constructor() {
super();
this.state = { count: 0 }
}
hndlChange() {
//here it's okay, It increasing count value
this.setState({ count: this.state.count + 1 });
//but here it printing previous value
console.log(this.state.count);
}
}
我正在调用这个函数。因为它增加了count 值,但是当我访问它时它返回以前的值。我想在同一个函数中访问最新更新的值我应该怎么做。
如何在同一函数中获取最新状态值
【问题讨论】:
标签: reactjs react-native react-redux