2 ms·
In practice, I don't think the "rules of hooks" [1] are a footgun, especially if you use the eslint rule. I'm confused about your second paragraph. useRef work
by jakelazaroff 5y ago
In practice, I don't think the "rules of hooks" [1] are a footgun, especially if you use the eslint rule.
I'm confused about your second paragraph. useRef works perfectly fine for keeping a reference stable so as to avoid triggering useEffect. In fact, that's one of the main tools I use to work around the useEffect dependency array.
[1] https://reactjs.org/docs/hooks-rules.html https://reactjs.org/docs/hooks-rules.html