Skip to content

Commit

Permalink
fix: Try and handle RSC race conditions
Browse files Browse the repository at this point in the history
See #714.
  • Loading branch information
franky47 committed Oct 28, 2024
1 parent c0bb912 commit cdbe5ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/nuqs/src/useQueryState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
useCallback,
useEffect,
useInsertionEffect,
useLayoutEffect,
useRef,
useState
} from 'react'
Expand Down Expand Up @@ -251,7 +251,7 @@ export function useQueryState<T = string>(
initialSearchParams?.get(key) ?? null
)

useEffect(() => {
useLayoutEffect(() => {
const query = initialSearchParams.get(key) ?? null
if (query === queryRef.current) {
return
Expand Down
4 changes: 2 additions & 2 deletions packages/nuqs/src/useQueryStates.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
useCallback,
useEffect,
useInsertionEffect,
useLayoutEffect,
useMemo,
useRef,
useState
Expand Down Expand Up @@ -113,7 +113,7 @@ export function useQueryStates<KeyMap extends UseQueryStatesKeysMap>(
initialSearchParams
)

useEffect(() => {
useLayoutEffect(() => {
const state = parseMap(
keyMap,
urlKeys,
Expand Down

0 comments on commit cdbe5ec

Please sign in to comment.