4 ms·
How would you use setTimeout to replace useEffect? useEffect works by running on each render (no dependencies) or running when rendering and dependencies chang
by steve_adams_86 5y ago
How would you use setTimeout to replace useEffect?
useEffect works by running on each render (no dependencies) or running when rendering and dependencies changed. Where does a timeout factor in?
useLayoutEffect also doesn't work based on the microtask queue - it uses React's internal scheduler, which I would imagine makes sense in the context of the library. Replicating it with queueMicrotask is probably not a trivial task.