Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

will useEffect callback clean up run if user closes tab or goes to a different website?

useEffect(() => {

  return () => clean_up();

}, [])

Will clean_up be runned if use closes tab or switches to a different website?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

No, and this is not particular to React. Once a document or window is closed (which includes being redirected to another page), no further JavaScript can execute in that window.

setTimeout will not run after the page is closed or redirected either, and neither will any other APIs provided by any other libraries, if they run on the client-side.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading