4 ms·
I don't think there's a way around tracking that `firstLoad` value. A `ref` is probably a better choice than a separate state value because you don't need to re
by sickcodebruh 6y ago
I don't think there's a way around tracking that `firstLoad` value. A `ref` is probably a better choice than a separate state value because you don't need to render when the component becomes aware that you're past the first render. You could do it in a simple hook:
function useFirstRenderComplete() {
const renderCountRef = useRef(0);
useEffect(() => {
if (renderCountRef.current) {
return;
}
renderCountRef.current += 1;
}, []);
return renderCountRef.current !== 0;
}