how to delete localstorage on browser close in react code example
Example: How to clear localStorage when browser/tab is closing
window.addEventListener("beforeunload", () => localStorage.removeItem('storageVariable'));
window.addEventListener("beforeunload", () => localStorage.removeItem('storageVariable'));