If code is inside return block of useEffect then It is intended to run before component unmounting or before execution of next scheduled useEffect.