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