react-hooks/exhaustive-deps issue

ESLint want's me to put that dependency but doing so will cause an infinite loop to rerender
11 Replies
-
-OP3y ago
-
-OP3y ago
anyone knows how to solve this issue? thanks in advance!
maxtreme
maxtreme3y ago
Why are You using memo here? It's for values. I guess you're looking for useEffect
Alex
Alex3y ago
But useEffect will have the same warning, right?
maxtreme
maxtreme3y ago
Yes, but you can just include it in the array - it's guaranteed to never change so it won't cause it to rerun In general you should be avoiding useEffect all together It might be a better idea to do this length check in handleNameQuery and fetch from there
-
-OP3y ago
okay this works
-
-OP3y ago
thanks! what about this one i got from tanstack table example?
-
-OP3y ago
-
-OP3y ago
Alex
Alex3y ago
Debounce and onChange won’t change normally, so including them to the dependency array should work if I‘m correct
maxtreme
maxtreme3y ago
yeah, should be fine i prefer useDebounce from react-use but both will achieve the same

Did you find this page helpful?