79778495

Date: 2025-09-29 20:05:21
Score: 0.5
Natty:
Report link

When we call window.location.reload():

useEffect(() => {
  console.log("Effect runs in line 1");

  return () => {
    console.log("Cleanup runs in line 15");
  };
}, []);

const handleReload = () => {
  window.location.reload();
};

When the component first mounts, we'll see 'Effect runs in line 1', now when we click a button that triggers reload, the browser discards the page. So we'll never see 'Cleanup run in line 15', cause React never got a chance to execute it.

Coming to the point answer : No window.location.reload() does not trigger the useEffect cleanup.
The browser reload wipes the page, React is gone, so React can’t run the cleanup.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): When we
  • Low reputation (1):
Posted by: Govind Choudhary