darekkay/dashboard

Prevent losing data when the page is closed

Opened this issue · 0 comments

User data is being stored in the local storage using redux-persist.
If the user enters some data (e.g. within the Text widget) and immediately closes the page, the data might not be saved.

One solution is to explicitly persist the store by listening to the beforeunload event. This depends on whether this action can be executed reliably for all supported browsers.

An alternative is to display a warning message when a page is being closed (using the same beforeunload event) as long as there are unpersisted changes (similar to what Todoist is doing).

In the future, the user account feature is likely to be implemented, making it necessary to store the data on the server. Hence, using something like sendBeacon might be required.