DEV Community

Discussion on: Learning React Hooks 1 useState

Collapse
 
marklai1998 profile image
Mark Lai

This post is just horribly wrong on setting state
every React developer should use call back function when the new state value is referencing the old state, that's the basic

this.setState(({counter})=>({ counter: prevCount + 10}))
setCount(({counter})=>({ counter: prevCount + 10}))