DEV Community

Discussion on: Increasing productivity: Best practices for React beginners.

Collapse
 
citronbrick profile image
CitronBrick

Shouldn't it be setCount(count=>count-1) ?

Collapse
 
qbentil profile image
Bentil Shadrack Documatic

In this case, the setCount function is taking another function which takes the cout as a param and return a decreased count by 1.

Which is kind of passing a redundant method to the setCount function.
You can simply pass the new value of count as an argument to the SetCount when calling it