Skip to content

Commit

Permalink
Revert "fix: WHS stabilisation (#457)"
Browse files Browse the repository at this point in the history
This reverts commit 5230814.
  • Loading branch information
franky47 committed Jan 17, 2024
1 parent 87566b2 commit b99c95c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ jobs:
# 14.0.2 is not compatible due to a prefetch issue
- latest
include:
# 14.0.3 requires the WHS flag
- next-version: '14.0.3'
window-history-support: true
# Current latest is 14.0.4
- next-version: latest
window-history-support: true
- next-version: latest
Expand Down
5 changes: 1 addition & 4 deletions packages/e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@ function supportsWHS() {
const pkgPath = new URL('./package.json', import.meta.url)
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
const nextVersion: string = pkg.dependencies.next
return (
semver.gte(nextVersion, '14.0.3-canary.6') &&
semver.lt(nextVersion, '14.0.5-canary.54')
)
return semver.gte(nextVersion, '14.0.3-canary.6')
}
16 changes: 9 additions & 7 deletions packages/nuqs/src/useQueryState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,15 @@ export function useQueryState<T = string>(
initialSearchParams?.get(key) ?? null
)

React.useEffect(() => {
const value = initialSearchParams.get(key) ?? null
const state = value === null ? null : safeParse(parse, value, key)
debug('[nuqs `%s`] syncFromUseSearchParams %O', key, state)
stateRef.current = state
setInternalState(state)
}, [initialSearchParams?.get(key), key])
if (process.env.__NEXT_WINDOW_HISTORY_SUPPORT) {
React.useEffect(() => {
const value = initialSearchParams.get(key) ?? null
const state = value === null ? null : safeParse(parse, value, key)
debug('[nuqs `%s`] syncFromUseSearchParams %O', key, state)
stateRef.current = state
setInternalState(state)
}, [initialSearchParams?.get(key), key])
}

// Sync all hooks together & with external URL changes
React.useInsertionEffect(() => {
Expand Down

0 comments on commit b99c95c

Please sign in to comment.