An idiomatic way to handle closed / closed websites using React / React Router

I want to send a cleanup request to my API server when the user leaves the website (actually closes the tab / browser, not just the SPA change page). Is there an idiomatic way to do this in an application using a React with React Router? Will the component be closed fire on the page? I guess not.

+4
source share
1 answer

The response here is not for you. Just do what you usually do for this. Also see answers to a related question.

The best place to post this subscription code is the lifecycle method componentDidMount. And don't forget to unsubscribe componentWillUnmountto prevent leakage.

+2
source

Source: https://habr.com/ru/post/1621804/


All Articles