deleteFromStorage doesn't call 'updateLocalState' event in other tab
swards opened this issue · comments
In use-localstorage.js, the onLocalStorageChange
function is called when a storage or localStorage event occurs. localStorage
events come from non-hook events in the same tab. storage
events come from another tab when localStorage is updated.
The event is being posted, but the localState of the hook is not being updated. It appears to be due to the code below.
const onLocalStorageChange = (event) => {
if (local_storage_events_1.isTypeOfLocalStorageChanged(event)) {
...
}
else {
if (event.key === key) {
if (event.newValue) { <<<<-------- THIS WILL BE FALSE IF NEW VALUE IS NULL
updateLocalState(tryParse(event.newValue));
}
}
}
};
This seems intentional - I'm trying to understand if there is a reason localState is not updated when deleteFromStorage
is called from another tab.
I can see this is fixed in 2.4.1