react在新版本中,修改了对state的处理方式

解决办法:1.由于state设置在了作用域内部,引用时可以使用如代码20行的方式改变this指向修改state的值。

React-Cannot read property 'state' of undefined at handleClick 报错原因

2.也可以使用setState设置

React-Cannot read property 'state' of undefined at handleClick 报错原因

相关文章: