@@ -7,7 +7,7 @@ import React from 'react'
7
7
import { debug } from './debug'
8
8
import type { Nullable , Options } from './defs'
9
9
import type { Parser } from './parsers'
10
- import { SYNC_EVENT_KEY , emitter , type CrossHookSyncPayload } from './sync'
10
+ import { emitter , type CrossHookSyncPayload } from './sync'
11
11
import {
12
12
FLUSH_RATE_LIMIT_MS ,
13
13
enqueueQueryStringUpdate ,
@@ -110,11 +110,6 @@ export function useQueryStates<KeyMap extends UseQueryStatesKeysMap>(
110
110
stateRef . current = state
111
111
setInternalState ( state )
112
112
}
113
- function syncFromURL ( search : URLSearchParams ) {
114
- const state = parseMap ( keyMap , search , queryRef . current , stateRef . current )
115
- debug ( '[nuq+ `%s`] syncFromURL %O' , keys , state )
116
- updateInternalState ( state )
117
- }
118
113
const handlers = Object . keys ( keyMap ) . reduce (
119
114
( handlers , key ) => {
120
115
handlers [ key as keyof V ] = ( { state, query } : CrossHookSyncPayload ) => {
@@ -140,14 +135,11 @@ export function useQueryStates<KeyMap extends UseQueryStatesKeysMap>(
140
135
} ,
141
136
{ } as Record < keyof V , ( payload : CrossHookSyncPayload ) => void >
142
137
)
143
-
144
- emitter . on ( SYNC_EVENT_KEY , syncFromURL )
145
138
for ( const key of Object . keys ( keyMap ) ) {
146
139
debug ( '[nuq+ `%s`] Subscribing to sync for `%s`' , keys , key )
147
140
emitter . on ( key , handlers [ key ] ! )
148
141
}
149
142
return ( ) => {
150
- emitter . off ( SYNC_EVENT_KEY , syncFromURL )
151
143
for ( const key of Object . keys ( keyMap ) ) {
152
144
debug ( '[nuq+ `%s`] Unsubscribing to sync for `%s`' , keys , key )
153
145
emitter . off ( key , handlers [ key ] )
0 commit comments