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
sheng2808
sheng280816mo ago
sheng2808
sheng280816mo ago
anyone knows how to solve this issue? thanks in advance!
maxtreme
maxtreme16mo ago
Why are You using memo here? It's for values. I guess you're looking for useEffect
Alex
Alex16mo ago
But useEffect will have the same warning, right?
maxtreme
maxtreme16mo 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
sheng2808
sheng280816mo ago
okay this works
sheng2808
sheng280816mo ago
thanks! what about this one i got from tanstack table example?
sheng2808
sheng280816mo ago
sheng2808
sheng280816mo ago
Alex
Alex16mo ago
Debounce and onChange won’t change normally, so including them to the dependency array should work if I‘m correct
maxtreme
maxtreme16mo ago
yeah, should be fine i prefer useDebounce from react-use but both will achieve the same