generated from chiffre-io/template-library
-
-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathrepro-862.tsx
55 lines (52 loc) · 1.43 KB
/
repro-862.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { parseAsString, useQueryState, useQueryStates } from 'nuqs'
import { useNavigate } from 'react-router-dom'
type Repro862Props = {
targetPath: string
}
export function Repro862UseQueryState({ targetPath }: Repro862Props) {
const navigate = useNavigate()
const [state, setState] = useQueryState('test')
return (
<>
<button id="setup" onClick={() => setState('pass')}>
Setup
</button>
<button id="navigate-clear" onClick={() => navigate(targetPath)}>
Navigate to {targetPath}
</button>
<button
id="navigate-persist"
onClick={() => navigate(targetPath + '?test=pass')}
>
Navigate to {targetPath + '?test=pass'}
</button>
<pre id="state">{state}</pre>
</>
)
}
export function Repro862UseQueryStates({ targetPath }: Repro862Props) {
const navigate = useNavigate()
const [{ state }, setState] = useQueryStates(
{
state: parseAsString
},
{ urlKeys: { state: 'test' } }
)
return (
<>
<button id="setup" onClick={() => setState({ state: 'pass' })}>
Setup
</button>
<button id="navigate-clear" onClick={() => navigate(targetPath)}>
Navigate to {targetPath}
</button>
<button
id="navigate-persist"
onClick={() => navigate(targetPath + '?test=pass')}
>
Navigate to {targetPath + '?test=pass'}
</button>
<pre id="state">{state}</pre>
</>
)
}