FITURE

If you can fight, fight.

首页 >> 分享>>React State Hook(setState) Not Work

React State Hook(setState) Not Work

Posted by fiture / 2018年11月04日 / 分享

Hey guys,You may was attracted to React new feature:  The Hooks. And just had a try with the latest react version:v16.7.0-alpha.

But wait! when you was about to use the latest api:useState and set some state to change it but it didn’t work, WTF?  You may start to doubt the life…

Yeah, I had just experienced such a thing today. So I want to write this for people who like me.

So check the webpack config in your repo: new webpack.HotModuleReplacementPlugin() plugin config and the webpack-hot-middleware  entry config. Just remove it.

The react hooks useState, “setState” works! The may be a bug with webpack or react, so now the only way we can do is remove the HRM and wait or if you find the problem and solved it just pull request to them.

发表评论

电子邮件地址不会被公开。 必填项已用*标注