DEV Community

Discussion on: How to not be a dinosaur.

Collapse
 
sapegin profile image
Artem Sapegin

The difference between setState and hooks is actually even bigger because your example is incorrect and may lead to using a stale state and saving an incorrect value, so you need to use a functional form of setState:

this.setState(prevState => ({ count: prevState.count + 1 }))

This is hard to understand and remember, and Hooks have no such problem at all.

Collapse
 
dreamdealer profile image
Johan van Tongeren

I think this illustrates how happy I was with hooks very well 😊