2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ /// <reference types="cypress" />
2
+
3
+ describe ( 'repro-774' , ( ) => {
4
+ it ( 'updates internal state on navigation' , ( ) => {
5
+ cy . visit ( '/app/repro-774' )
6
+ cy . contains ( '#hydration-marker' , 'hydrated' ) . should ( 'be.hidden' )
7
+ cy . get ( '#trigger-a' ) . click ( )
8
+ cy . get ( '#value-a' ) . should ( 'have.text' , 'a' )
9
+ cy . get ( '#value-b' ) . should ( 'be.empty' )
10
+ cy . get ( '#link' ) . click ( )
11
+ cy . get ( '#value-a' ) . should ( 'be.empty' )
12
+ cy . get ( '#value-b' ) . should ( 'be.empty' )
13
+ cy . get ( '#trigger-b' ) . click ( )
14
+ cy . get ( '#value-a' ) . should ( 'be.empty' )
15
+ cy . get ( '#value-b' ) . should ( 'have.text' , 'b' )
16
+ } )
17
+ } )
Original file line number Diff line number Diff line change
1
+ 'use client'
2
+
3
+ import Link from 'next/link'
4
+ import { parseAsString , useQueryStates } from 'nuqs'
5
+ import { Suspense } from 'react'
6
+
7
+ export default function Home ( ) {
8
+ return (
9
+ < >
10
+ < nav >
11
+ < Link id = "link" href = "/app/repro-774" >
12
+ Reset
13
+ </ Link >
14
+ </ nav >
15
+ < Suspense >
16
+ < Client />
17
+ </ Suspense >
18
+ </ >
19
+ )
20
+ }
21
+
22
+ const searchParams = {
23
+ a : parseAsString . withDefault ( '' ) ,
24
+ b : parseAsString . withDefault ( '' )
25
+ }
26
+
27
+ function Client ( ) {
28
+ const [ { a, b } , setSearchParams ] = useQueryStates ( searchParams )
29
+ return (
30
+ < >
31
+ < button onClick = { ( ) => setSearchParams ( { a : 'a' } ) } id = "trigger-a" >
32
+ Set A
33
+ </ button >
34
+ < button onClick = { ( ) => setSearchParams ( { b : 'b' } ) } id = "trigger-b" >
35
+ Set B
36
+ </ button >
37
+ < span id = "value-a" > { a } </ span >
38
+ < span id = "value-b" > { b } </ span >
39
+ </ >
40
+ )
41
+ }
0 commit comments