State updates scheduled inside useLayoutEffect are flushed before paint, allowing a second render that the user does not see halfway.