DEV Community

loading...

Discussion on: Common UseEffects mistakes that even seniors are making

Collapse
sleeplessbyte profile image
Derk-Jan Karrenbeld

The post is full with bad advice. It's a good attempt, but a bad resource.

For example:

In example 3 you must always use primitives as dependencies never reference types such as *Functions, Objects or Arrays. Use only string, boolean, number.

You can use whatever you want as a dependency in the second argument of a useEffect hook, but if you want it to work as intended, the value must be stable: that is, not be regenerated each render. You can use functions, objects, and arrays.

Collapse
hernanif1 profile image
Hernani Fernandes Author • Edited

Hi Derk Jan,
Thank you for your feedback.
I updated this post so I removed that wrong typos and I'm trying to make my point clearer.
About the primitives as dependencies I'm trying to explain that most of the devs are simply filling in this parameter and are not aware about why.
Let me know if you have any resource that explains better about this specific part.

This is my first post so I was trying to make it fine instead of make it perfect because I procrastinated it for a long time.
Thank you for helping me to make it better.