Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

linkProps.tsx

73 lines1.5 KB

1import * as React from 'react'
2import { Link, linkOptions, createFileRoute } from '@tanstack/react-router'
3import {
4 customRedirect,
5 ListItems,
6 MyLink,
7 useCustomNavigate,
8} from '~/typePrimitives'
9​
10export const Route = createFileRoute('/linkProps')({
11 component: LinkPropsPage,
12 loader: () => {
13 throw customRedirect({
14 to: '/search/searchPlaceholder',
15 search: {
16 searchPlaceholder: 'searchPlaceholder',
17 rootSearch: 0,
18 page: 0,
19 offset: 0,
20 search: 'hi',
21 },
22 })
23 },
24})
25​
26function LinkPropsPage() {
27 useCustomNavigate({
28 to: '/search/searchPlaceholder',
29 search: {
30 searchPlaceholder: 'searchPlaceholder',
31 rootSearch: 0,
32 page: 0,
33 offset: 0,
34 search: 'hi',
35 },
36 })
37​
38 const linkProps = linkOptions({
39 to: '/absolute',
40 })
41​
42 return (
43 <>
44 <MyLink
45 from="/search/searchPlaceholder"
46 to="../searchPlaceholder"
47 search={{
48 searchPlaceholder: 'searchPlaceholder',
49 rootSearch: 0,
50 page: 0,
51 offset: 0,
52 search: 'hi',
53 }}
54 />
55 <ListItems
56 from="/search/searchPlaceholder"
57 items={[
58 {
59 to: '../searchPlaceholder',
60 search: {
61 searchPlaceholder: 'searchPlaceholder',
62 rootSearch: 0,
63 page: 0,
64 offset: 0,
65 search: 'hi',
66 },
67 },
68 ]}
69 />
70 <Link {...linkProps} />
71 </>
72 )