
React FAQ
The React Show
00:00
React - Is There a Dependency Array?
Dependency aray was designed to be used for performance optimization. Instead of using it, use i statement at the very beginning of your used effect that checks if body should run. This could also be functions that get passed in, you know, things coming from ue state or wherever. It doesn't matter if it's a value that could theoretically change in your programme. I needs to be in there if it's referenced inside the used effect. And so this is why i always tell people, just don't use that dependency aray unless you actually have a performance bottle neck.
Transcript
Play full episode