Like useEffect, useLayoutEffect can return a cleanup function that runs before the next setup with changed dependencies and on unmount.