Open History to see the last commit
1import { Link, useParams, useSearch } from '@tanstack/react-router'
2β
3const probes = Array.from({ length: 10 }, (_, index) => index)
4β
5function runSelectorWork(input: string, salt: number) {
6 let value = salt
7β
8 for (let index = 0; index < input.length; index++) {
9 value = (value * 33 + input.charCodeAt(index) + index) >>> 0
10 }
11β
12 for (let index = 0; index < 16; index++) {
13 value = (value ^ (value << 13)) >>> 0
14 value = (value ^ (value >> 17)) >>> 0
15 value = (value ^ (value << 5)) >>> 0
16 }
17β
18 return value
19}
20β
21function ParamsProbe({ salt }: { salt: number }) {
22 const params = useParams({
23 strict: false,
24 select: (nextParams) =>
25 runSelectorWork(
26 `${nextParams.a ?? ''}/${nextParams.b ?? ''}/${nextParams.c ?? ''}/${nextParams.d ?? ''}`,
27 salt,
28 ),
29 })
30β
31 void params
32β
33 return null
34}
35β
36function SearchProbe({ salt }: { salt: number }) {
37 const search = useSearch({
38 strict: false,
39 select: (nextSearch) => runSelectorWork(String(nextSearch.q ?? ''), salt),
40 })
41β
42 void search
43β
44 return null
45}
46β
47function LinkProbe({ salt }: { salt: number }) {
48 const value = String((salt % 97) + 1)
49β
50 return (
51 <Link
52 to="/$a/$b/$c/$d"
53 params={{
54 a: `a-${value}`,
55 b: `b-${value}`,
56 c: `c-${value}`,
57 d: `d-${value}`,
58 }}
59 search={{ q: `q-${value}` }}
60 preload={false}
61 >
62 Link
63 </Link>
64 )
65}
66β
67export function RouteWorkload() {
68 return (
69 <>
70 {probes.map((probe) => (
71 <ParamsProbe key={`params-${probe}`} salt={probe + 1} />
72 ))}
73 {probes.map((probe) => (
74 <SearchProbe key={`search-${probe}`} salt={probe + 11} />
75 ))}
76 {probes.map((probe) => (
77 <LinkProbe key={`link-${probe}`} salt={probe + 21} />
78 ))}
79 </>
80 )
81}