Chapter 12 · Example 4 · Escaping Flickering UI with useLayoutEffect
Splitting work with setTimeout
Wrapping each border change in setTimeout breaks the work into separate tasks, letting the browser repaint between them so the color transition is visible.
Loading live editor…