If the UI must measure layout and update position before the user sees it, useLayoutEffect can avoid visible flicker.