next.js
01002efd - chore(dev-overlay): Minor cleanups to useDelayedRender hook (#79119)

Commit
269 days ago
chore(dev-overlay): Minor cleanups to useDelayedRender hook (#79119) I noticed a few minor issues/nits while reading through this: - The refs aren't needed for a local variable. `useEffect`'s cancellation is called every time the inputs to `useEffect` change, so there's no need to hold timeout ids across `useEffects`. - Getting rid of the refs also lets use get rid of `useCallback`. Note: It's totally acceptable and idiomatic to call `clearTimeout` with a potentially-`undefined` value. That's explicitly allowed in the typescript definition. - `useEffect` shouldn't depend on the object. The object destructuring should happen outside of the `useEffect`. Hook dependencies are compared via referential equality, not structural equality, so this could have unintended effects. - Most places in Next.js seem to use the global `setTimeout` directly instead of accessing it through `window`? I tested this by increasing the duration of the animation, playing with the overlay menu, and watching the DOM for the unmount: [Screen Recording 2025-05-12 at 4.25.32 PM.mov <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/HAZVitxRNnZz8QMiPn4a/47d98858-e344-4532-b60f-c68561f5347f.mov" />](https://app.graphite.dev/media/video/HAZVitxRNnZz8QMiPn4a/47d98858-e344-4532-b60f-c68561f5347f.mov)
Author
bgw bgw
Parents
Loading