Skip to content

Commit 0781b37

Browse files
authored
chore(examples): fix router for react and solid basic sandboxes (#26)
1 parent 5f40bfa commit 0781b37

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

examples/react/basic/src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createRoot } from 'react-dom/client'
22
import Devtools from './setup'
33
import { queryPlugin } from './plugin'
4+
45
setTimeout(() => {
56
queryPlugin.emit('test', {
67
title: 'Test Event',
@@ -12,10 +13,11 @@ setTimeout(() => {
1213
queryPlugin.on('test', (event) => {
1314
console.log('Received test event:', event)
1415
})
16+
1517
function App() {
1618
return (
1719
<div>
18-
<h1>TanStack Devtools Basic Example</h1>
20+
<h1>TanStack Devtools React Basic Example</h1>
1921
<Devtools />
2022
</div>
2123
)

examples/react/basic/src/setup.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
22
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
33
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
44
import {
5-
Outlet,
65
Link,
7-
createRouter,
8-
createRoute,
6+
Outlet,
7+
RouterProvider,
98
createRootRoute,
9+
createRoute,
10+
createRouter,
1011
} from '@tanstack/react-router'
11-
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
1212
import { TanstackDevtools } from '@tanstack/react-devtools'
1313

1414
const rootRoute = createRootRoute({
@@ -24,7 +24,6 @@ const rootRoute = createRootRoute({
2424
</div>
2525
<hr />
2626
<Outlet />
27-
<TanStackRouterDevtools />
2827
</>
2928
),
3029
})
@@ -41,7 +40,11 @@ const indexRoute = createRoute({
4140
},
4241
})
4342
function About() {
44-
return <div className="p-2">Hello from About!</div>
43+
return (
44+
<div className="p-2">
45+
<h3>Hello from About!</h3>
46+
</div>
47+
)
4548
}
4649

4750
const aboutRoute = createRoute({
@@ -72,6 +75,7 @@ export default function DevtoolsExample() {
7275
},
7376
]}
7477
/>
78+
<RouterProvider router={router} />
7579
</QueryClientProvider>
7680
</>
7781
)

examples/solid/basic/src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { render } from 'solid-js/web'
22
import Devtools from './setup'
3+
34
function App() {
45
return (
56
<div>
6-
<h1>TanStack Devtools Basic Example</h1>
7+
<h1>TanStack Devtools Solid Basic Example</h1>
78
<Devtools />
89
</div>
910
)

examples/solid/basic/src/setup.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,28 @@ import { QueryClient, QueryClientProvider } from '@tanstack/solid-query'
22
import { SolidQueryDevtools } from '@tanstack/solid-query-devtools'
33
import { TanStackRouterDevtoolsPanel } from '@tanstack/solid-router-devtools'
44
import {
5+
Link,
56
Outlet,
6-
createRouter,
7-
createRoute,
7+
RouterProvider,
88
createRootRoute,
9+
createRoute,
10+
createRouter,
911
} from '@tanstack/solid-router'
10-
import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'
1112
import { TanstackDevtools } from '@tanstack/solid-devtools'
13+
1214
const rootRoute = createRootRoute({
1315
component: () => (
1416
<>
15-
<div class="p-2 flex gap-2"></div>
17+
<div class="p-2 flex gap-2">
18+
<Link to="/" class="[&.active]:font-bold">
19+
Home
20+
</Link>{' '}
21+
<Link to="/about" class="[&.active]:font-bold">
22+
About
23+
</Link>
24+
</div>
1625
<hr />
1726
<Outlet />
18-
<TanStackRouterDevtools />
1927
</>
2028
),
2129
})
@@ -32,8 +40,13 @@ const indexRoute = createRoute({
3240
},
3341
})
3442
function About() {
35-
return <div class="p-2">Hello from About!</div>
43+
return (
44+
<div class="p-2">
45+
<h3>Hello from About!</h3>
46+
</div>
47+
)
3648
}
49+
3750
const aboutRoute = createRoute({
3851
getParentRoute: () => rootRoute,
3952
path: '/about',
@@ -65,6 +78,7 @@ export default function DevtoolsExample() {
6578
},
6679
]}
6780
/>
81+
<RouterProvider router={router} />
6882
</>
6983
)
7084
}

0 commit comments

Comments
 (0)