Skip to content

Commit 3973990

Browse files
committed
fix: Referential stability for the state updater function
1 parent a67b403 commit 3973990

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/nuqs/src/useQueryState.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,17 @@ export function useQueryState<T = string>(
294294
emitter.emit(key, { state: newValue, query })
295295
return scheduleFlushToURL(adapter)
296296
},
297-
[key, history, shallow, scroll, throttleMs, startTransition, adapter]
297+
[
298+
key,
299+
history,
300+
shallow,
301+
scroll,
302+
throttleMs,
303+
startTransition,
304+
adapter.updateUrl,
305+
adapter.getSearchParamsSnapshot,
306+
adapter.rateLimitFactor
307+
]
298308
)
299309
return [internalState ?? defaultValue ?? null, update]
300310
}

packages/nuqs/src/useQueryStates.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,16 @@ export function useQueryStates<KeyMap extends UseQueryStatesKeysMap>(
232232
return scheduleFlushToURL(adapter)
233233
},
234234
[
235-
keyMap,
235+
stateKeys,
236236
history,
237237
shallow,
238238
scroll,
239239
throttleMs,
240240
startTransition,
241241
resolvedUrlKeys,
242-
adapter,
242+
adapter.updateUrl,
243+
adapter.getSearchParamsSnapshot,
244+
adapter.rateLimitFactor,
243245
defaultValues
244246
]
245247
)

0 commit comments

Comments
 (0)