Skip to content

Commit 93f1b65

Browse files
committed
chore: Simplify effect on core
1 parent 331b587 commit 93f1b65

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

packages/nuqs/src/useQueryState.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
useCallback,
3-
useEffect,
4-
useInsertionEffect,
5-
useRef,
6-
useState
7-
} from 'react'
1+
import { useCallback, useEffect, useRef, useState } from 'react'
82
import { useAdapter } from './adapters/lib/context'
93
import { debug } from './debug'
104
import type { Options } from './defs'
@@ -260,7 +254,7 @@ export function useQueryState<T = string>(
260254
}, [initialSearchParams?.get(key), key])
261255

262256
// Sync all hooks together & with external URL changes
263-
useInsertionEffect(() => {
257+
useEffect(() => {
264258
function updateInternalState({ state, query }: CrossHookSyncPayload) {
265259
debug('[nuqs `%s`] updateInternalState %O', key, state)
266260
stateRef.current = state

packages/nuqs/src/useQueryStates.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
useCallback,
3-
useEffect,
4-
useInsertionEffect,
5-
useMemo,
6-
useRef,
7-
useState
8-
} from 'react'
1+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
92
import { useAdapter } from './adapters/lib/context'
103
import { debug } from './debug'
114
import type { Nullable, Options, UrlKeys } from './defs'
@@ -139,7 +132,7 @@ export function useQueryStates<KeyMap extends UseQueryStatesKeysMap>(
139132
])
140133

141134
// Sync all hooks together & with external URL changes
142-
useInsertionEffect(() => {
135+
useEffect(() => {
143136
function updateInternalState(state: V) {
144137
debug('[nuq+ `%s`] updateInternalState %O', stateKeys, state)
145138
stateRef.current = state

0 commit comments

Comments
 (0)