File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -180,8 +180,11 @@ export function useStorage<T extends(string | number | boolean | object | null)>
180
180
if ( window && listenToStorageChanges ) {
181
181
tryOnMounted ( ( ) => {
182
182
// this should be fine since we are in a mounted hook
183
- useEventListener ( window , 'storage' , update )
184
- useEventListener ( window , customStorageEventName , updateFromCustomEvent )
183
+ if ( storage instanceof Storage )
184
+ useEventListener ( window , 'storage' , update )
185
+ else
186
+ useEventListener ( window , customStorageEventName , updateFromCustomEvent )
187
+
185
188
if ( initOnMounted )
186
189
update ( )
187
190
} )
@@ -195,7 +198,7 @@ export function useStorage<T extends(string | number | boolean | object | null)>
195
198
// send custom event to communicate within same page
196
199
// importantly this should _not_ be a StorageEvent since those cannot
197
200
// be constructed with a non-built-in storage area
198
- if ( window ) {
201
+ if ( window && ! ( storage instanceof Storage ) ) {
199
202
window . dispatchEvent ( new CustomEvent < StorageEventLike > ( customStorageEventName , {
200
203
detail : {
201
204
key,
You can’t perform that action at this time.
0 commit comments