Skip to content

Commit 107b21e

Browse files
committed
feat: moving to the new TanStack devtools
1 parent e93d1a4 commit 107b21e

File tree

21 files changed

+146
-35
lines changed

21 files changed

+146
-35
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { EventClient } from '@tanstack/devtools-event-client'
2+
import { useState, useEffect } from 'react'
3+
4+
import { store, fullName } from './demo-store'
5+
6+
type EventMap = {
7+
'store-devtools:state': {
8+
firstName: string
9+
lastName: string
10+
fullName: string
11+
}
12+
}
13+
14+
class StoreDevtoolsEventClient extends EventClient<EventMap> {
15+
constructor() {
16+
super({
17+
pluginId: 'store-devtools',
18+
})
19+
}
20+
}
21+
22+
const sdec = new StoreDevtoolsEventClient()
23+
24+
store.subscribe(() => {
25+
sdec.emit('state', {
26+
firstName: store.state.firstName,
27+
lastName: store.state.lastName,
28+
fullName: fullName.state,
29+
})
30+
})
31+
32+
function DevtoolPanel() {
33+
const [state, setState] = useState<EventMap['store-devtools:state']>(() => ({
34+
firstName: store.state.firstName,
35+
lastName: store.state.lastName,
36+
fullName: fullName.state,
37+
}))
38+
39+
useEffect(() => {
40+
return sdec.on('state', (e) => setState(e.payload))
41+
}, [])
42+
43+
return (
44+
<div className="p-4 grid gap-4 grid-cols-[1fr_10fr]">
45+
<div className="text-sm font-bold text-gray-500 whitespace-nowrap">
46+
First Name
47+
</div>
48+
<div className="text-sm">{state?.firstName}</div>
49+
<div className="text-sm font-bold text-gray-500 whitespace-nowrap">
50+
Last Name
51+
</div>
52+
<div className="text-sm">{state?.lastName}</div>
53+
<div className="text-sm font-bold text-gray-500 whitespace-nowrap">
54+
Full Name
55+
</div>
56+
<div className="text-sm">{state?.fullName}</div>
57+
</div>
58+
)
59+
}
60+
61+
export default {
62+
name: 'TanStack Store',
63+
render: <DevtoolPanel />,
64+
}

frameworks/react-cra/add-ons/store/info.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,12 @@
1212
"path": "src/routes/demo.store.tsx",
1313
"jsName": "StoreDemo"
1414
}
15+
],
16+
"integrations": [
17+
{
18+
"type": "devtools",
19+
"path": "src/lib/demo-store-devtools.tsx",
20+
"jsName": "StoreDevtools"
21+
}
1522
]
1623
}

frameworks/react-cra/add-ons/store/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"dependencies": {
33
"@tanstack/store": "^0.7.0",
44
"@tanstack/react-store": "^0.7.0"
5+
},
6+
"devDependencies": {
7+
"@tanstack/devtools-event-client": "^0.2.1"
58
}
69
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
2+
3+
export default {
4+
name: 'Tanstack Query',
5+
render: <ReactQueryDevtoolsPanel />,
6+
}

frameworks/react-cra/add-ons/tanstack-query/assets/src/integrations/tanstack-query/layout.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.

frameworks/react-cra/add-ons/tanstack-query/info.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"jsName": "TanStackQueryProvider"
2121
},
2222
{
23-
"type": "layout",
24-
"path": "src/integrations/tanstack-query/layout.tsx",
25-
"jsName": "TanStackQueryLayout"
23+
"type": "devtools",
24+
"path": "src/integrations/tanstack-query/devtools.tsx",
25+
"jsName": "TanStackQueryDevtools"
2626
}
2727
]
2828
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
33
"@tanstack/react-query": "^5.66.5",
4-
"@tanstack/react-query-devtools": "^5.66.5"
4+
"@tanstack/react-query-devtools": "^5.84.2"
55
}
66
}

frameworks/react-cra/project/base/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
"test": "vitest run"
1111
},
1212
"dependencies": {
13+
"@tanstack/react-devtools": "^0.2.2",
1314
"@tanstack/react-router": "^1.130.2",
14-
"@tanstack/react-router-devtools": "^1.130.2",
15+
"@tanstack/react-router-devtools": "^1.131.5",
1516
"react": "^19.0.0",
1617
"react-dom": "^19.0.0"
1718
},

frameworks/react-cra/project/base/src/routes/__root.tsx.ejs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<% if (!fileRouter) { ignoreFile() } %>import { <% if (addOnEnabled.start) { %>
22
HeadContent<% } else { %>Outlet<% } %><% if (addOnEnabled.start) { %>, Scripts<% } %>, <% if (addOnEnabled["tanstack-query"]) { %>createRootRouteWithContext<% } else { %>createRootRoute<% } %> } from '@tanstack/react-router'
3-
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
3+
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools';
4+
import { TanstackDevtools } from '@tanstack/react-devtools'
45
<% if (addOns.length) { %>
56
import Header from '../components/Header'
6-
<% } %><% for(const integration of integrations.filter(i => i.type === 'layout' || i.type === 'provider')) { %>
7-
import <%= integration.jsName %> from "<%= relativePath(integration.path) %>";
7+
<% } %><% for(const integration of integrations.filter(i => i.type === 'layout' || i.type === 'provider' || i.type === 'devtools')) { %>
8+
import <%= integration.jsName %> from '<%= relativePath(integration.path, true) %>'
89
<% } %>
910
<% if (addOnEnabled.start) { %>
1011
import appCss from '../styles.css?url'
@@ -53,7 +54,18 @@ export const Route = <% if (addOnEnabled["tanstack-query"]) { %>createRootRouteW
5354
<% for(const integration of integrations.filter(i => i.type === 'provider')) { %><<%= integration.jsName %>>
5455
<% } %><% if (addOns.length) { %><Header />
5556
<% } %><Outlet />
56-
<TanStackRouterDevtools />
57+
<TanstackDevtools
58+
config={{
59+
position: 'bottom-left',
60+
}}
61+
plugins={[
62+
{
63+
name: 'Tanstack Router',
64+
render: <TanStackRouterDevtoolsPanel />,
65+
},
66+
<% for(const integration of integrations.filter(i => i.type === 'devtools')) { %><%= integration.jsName %>,<% } %>
67+
]}
68+
/>
5769
<% for(const integration of integrations.filter(i => i.type === 'layout')) { %><<%= integration.jsName %> />
5870
<% } %><% for(const integration of integrations.filter(i => i.type === 'provider').reverse()) { %></<%= integration.jsName %>>
5971
<% } %>
@@ -72,7 +84,18 @@ function RootDocument({ children }: { children: React.ReactNode }) {
7284
<% for(const integration of integrations.filter(i => i.type === 'provider')) { %><<%= integration.jsName %>>
7385
<% } %><% if (addOns.length) { %><Header />
7486
<% } %>{children}
75-
<TanStackRouterDevtools />
87+
<TanstackDevtools
88+
config={{
89+
position: 'bottom-left',
90+
}}
91+
plugins={[
92+
{
93+
name: 'Tanstack Router',
94+
render: <TanStackRouterDevtoolsPanel />,
95+
},
96+
<% for(const integration of integrations.filter(i => i.type === 'devtools')) { %><%= integration.jsName %>,<% } %>
97+
]}
98+
/>
7699
<% for(const integration of integrations.filter(i => i.type === 'layout')) { %><<%= integration.jsName %> />
77100
<% } %><% for(const integration of integrations.filter(i => i.type === 'provider').reverse()) { %></<%= integration.jsName %>>
78101
<% } %><Scripts />

frameworks/react-cra/tests/snapshots/react-cra/cr-js-form-npm.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)