Skip to content

Commit 953488a

Browse files
mehdibhasnowystingerreidbarber
authored
fix(docs): update tanstack start routing setup (#9396)
* fix(docs): update tanstack start routing setup * Apply suggestion from @snowystinger * fix spacing * Apply suggestion from @snowystinger * include in S2 router docs --------- Co-authored-by: Robert Snow <snowystinger@gmail.com> Co-authored-by: Robert Snow <rsnow@adobe.com> Co-authored-by: Reid Barber <reid@reidbarber.com>
1 parent 92aa6f4 commit 953488a

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

packages/dev/s2-docs/src/routers-s2.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,14 @@ import {Step, Counter} from './Step';
6464
<Provider
6565
background="base"
6666
router={{
67-
navigate: (href, opts) => router.navigate({...href, ...opts}),
68-
useHref: href => router.buildLocation(href).href
67+
navigate: (href, opts) => {
68+
if (typeof href === "string") return;
69+
return router.navigate({ ...href, ...opts });
70+
},
71+
useHref: (href) => {
72+
if (typeof href === "string") return href;
73+
return router.buildLocation(href).href;
74+
}
6975
}}>
7076
{/*- end highlight -*/}
7177
{/* Your app here... */}

packages/dev/s2-docs/src/routers.mdx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Counter} from './Step';
22

33
<Counter />Render a `RouterProvider` at the root of your app to enable React Aria links to use your client side router. This accepts two props:
4-
4+
55
1. `navigate` – a function received from your router for performing a client side navigation programmatically.
66
2. `useHref` (optional) – converts a router-specific href to a native HTML href, e.g. prepending a base path.
77

@@ -58,9 +58,15 @@ export const Route = createRootRoute({
5858
let router = useRouter();
5959
return (
6060
/*- begin highlight -*/
61-
<RouterProvider
62-
navigate={(href, opts) => router.navigate({...href, ...opts})}
63-
useHref={href => router.buildLocation(href).href}>
61+
<RouterProvider
62+
navigate={(href, opts) => {
63+
if (typeof href === "string") return;
64+
return router.navigate({ ...href, ...opts });
65+
}}
66+
useHref={(href) => {
67+
if (typeof href === "string") return href;
68+
return router.buildLocation(href).href;
69+
}}>
6470
{/*- end highlight -*/}
6571
{/* Your app here... */}
6672
</RouterProvider>

0 commit comments

Comments
 (0)