When a key is removed, evt.newValue is set to null, and thus gets filtered out in this conditional. I have confirmed through while debugging, and the second tab does receive the storage event correctly, but gets filtered out here.
This seems like a bug, because there's an invocation to the event handlers with the value null on the during the remove step, however that only applies to the current tab and is not synced to other tabs.
Prior Issues
None that I could find
What is the current behavior?
Remove a local storage key in one tab, observe that it does not trigger an update in another tab.
Steps to Reproduce
What is the expected behavior?
Key removals should be synchronized across tabs
Potential cause
I believe the cause is in this event handler, specifically the
evt.newValue
condition. https://github.com/react-hookz/web/blob/579a445fcc9f4f4bb5b9d5e670b2e57448b4ee50/src/useStorageValue/index.ts#L28-L32When a key is removed,
evt.newValue
is set to null, and thus gets filtered out in this conditional. I have confirmed through while debugging, and the second tab does receive the storage event correctly, but gets filtered out here.This seems like a bug, because there's an invocation to the event handlers with the value
null
on the during theremove
step, however that only applies to the current tab and is not synced to other tabs.https://github.com/react-hookz/web/blob/579a445fcc9f4f4bb5b9d5e670b2e57448b4ee50/src/useStorageValue/index.ts#L235
Environment Details
@react-hookz/web
version: 23.1.0 and 24.0.4react
version: 18.2.0react-dom
version: 18.2.0typescript
version: 5.4.4