Skip to content

Commit 5230814

Browse files
committed
fix: WHS stabilisation (#457)
* fix: WHS has been stabilised * chore: Add test suite for 14.0.3 with WHS
1 parent fde9ad5 commit 5230814

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

.github/workflows/ci-cd.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
# 14.0.2 is not compatible due to a prefetch issue
3131
- latest
3232
include:
33+
# 14.0.3 requires the WHS flag
34+
- next-version: '14.0.3'
35+
window-history-support: true
36+
# Current latest is 14.0.4
3337
- next-version: latest
3438
window-history-support: true
3539
- next-version: latest

packages/e2e/cypress.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ function supportsWHS() {
3030
const pkgPath = new URL('./package.json', import.meta.url)
3131
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
3232
const nextVersion: string = pkg.dependencies.next
33-
return semver.gte(nextVersion, '14.0.3-canary.6')
33+
return (
34+
semver.gte(nextVersion, '14.0.3-canary.6') &&
35+
semver.lt(nextVersion, '14.0.5-canary.54')
36+
)
3437
}

packages/nuqs/src/useQueryState.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,13 @@ export function useQueryState<T = string>(
240240
initialSearchParams?.get(key) ?? null
241241
)
242242

243-
if (process.env.__NEXT_WINDOW_HISTORY_SUPPORT) {
244-
React.useEffect(() => {
245-
const value = initialSearchParams.get(key) ?? null
246-
const state = value === null ? null : safeParse(parse, value, key)
247-
debug('[nuqs `%s`] syncFromUseSearchParams %O', key, state)
248-
stateRef.current = state
249-
setInternalState(state)
250-
}, [initialSearchParams?.get(key), key])
251-
}
243+
React.useEffect(() => {
244+
const value = initialSearchParams.get(key) ?? null
245+
const state = value === null ? null : safeParse(parse, value, key)
246+
debug('[nuqs `%s`] syncFromUseSearchParams %O', key, state)
247+
stateRef.current = state
248+
setInternalState(state)
249+
}, [initialSearchParams?.get(key), key])
252250

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

0 commit comments

Comments
 (0)