Skip to content

Commit 7f95ac7

Browse files
committed
feat: now Solid has add-ons
1 parent 53adf33 commit 7f95ac7

File tree

13 files changed

+193
-5
lines changed

13 files changed

+193
-5
lines changed

templates/react/add-on/react-query/info.json renamed to templates/react/add-on/tanstack-query/info.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "React Query",
2+
"name": "TanStack Query",
33
"description": "Integrate TanStack Query into your application.",
44
"phase": "add-on",
55
"link": "https://tanstack.com/query/latest",
@@ -23,8 +23,8 @@
2323
},
2424
"routes": [
2525
{
26-
"url": "/demo/react-query",
27-
"name": "React Query"
26+
"url": "/demo/tanstack-query",
27+
"name": "TanStack Query"
2828
}
2929
]
3030
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Store } from '@tanstack/store'
2+
3+
export const store = new Store({
4+
count: 0,
5+
})
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { createFileRoute } from '@tanstack/solid-router'
2+
import { useStore } from '@tanstack/solid-store'
3+
4+
import { store } from '../lib/demo-store'
5+
6+
export const Route = createFileRoute('/demo/store/page1')({
7+
component: App,
8+
})
9+
10+
function App() {
11+
const count = useStore(store, (state) => state.count)
12+
13+
return (
14+
<div class="p-4 flex flex-col gap-2">
15+
<p class="text-2xl">Global Count: {count}</p>
16+
<button
17+
onClick={() => {
18+
store.setState((state) => ({
19+
count: state.count + 1,
20+
}))
21+
}}
22+
class="mt-4 inline-flex items-center px-6 py-3 border border-transparent shadow-sm text-base font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
23+
>
24+
Increment count
25+
</button>
26+
</div>
27+
)
28+
}
29+
30+
export default App
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { createFileRoute } from '@tanstack/solid-router'
2+
import { useStore } from '@tanstack/solid-store'
3+
4+
import { store } from '../lib/demo-store'
5+
6+
export const Route = createFileRoute('/demo/store/page2')({
7+
component: App,
8+
})
9+
10+
function App() {
11+
const count = useStore(store, (state) => state.count)
12+
13+
return (
14+
<div class="p-4 flex flex-col gap-2">
15+
<p class="text-2xl">Global Count: {count}</p>
16+
<button
17+
onClick={() => {
18+
store.setState((state) => ({
19+
count: state.count + 10,
20+
}))
21+
}}
22+
class="mt-4 inline-flex items-center px-6 py-3 border border-transparent shadow-sm text-base font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
23+
>
24+
Increment count by 10
25+
</button>
26+
</div>
27+
)
28+
}
29+
30+
export default App
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "Store",
3+
"description": "Add TanStack Store to your application.",
4+
"phase": "add-on",
5+
"link": "https://tanstack.com/store/latest",
6+
"routes": [
7+
{
8+
"url": "/demo/store/page1",
9+
"name": "Store Pg 1"
10+
},
11+
{
12+
"url": "/demo/store/page2",
13+
"name": "Store Pg 2"
14+
}
15+
]
16+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": {
3+
"@tanstack/store": "^0.7.0",
4+
"@tanstack/solid-store": "^0.7.0"
5+
}
6+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { createFileRoute } from '@tanstack/solid-router'
2+
import { createQuery } from '@tanstack/solid-query'
3+
4+
export const Route = createFileRoute('/demo/tanstack-query')({
5+
component: App,
6+
})
7+
8+
function App() {
9+
const peopleQuery = createQuery(() => ({
10+
queryKey: ['people'],
11+
queryFn: () =>
12+
fetch('https://swapi.dev/api/people')
13+
.then((res) => res.json())
14+
.then((data) => data.results as Array<{ name: string }>),
15+
initialData: [],
16+
}))
17+
18+
return (
19+
<div class="p-4">
20+
<h1 class="text-2xl mb-4">People list from Swapi</h1>
21+
<ul>
22+
{peopleQuery.data.map((person) => (
23+
<li>{person.name}</li>
24+
))}
25+
</ul>
26+
</div>
27+
)
28+
}
29+
30+
export default App
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "TanStack Query",
3+
"description": "Integrate TanStack Query into your application.",
4+
"phase": "add-on",
5+
"link": "https://tanstack.com/query/latest",
6+
"main": {
7+
"imports": [
8+
"import { QueryClient, QueryClientProvider } from '@tanstack/solid-query'"
9+
],
10+
"initialize": ["const queryClient = new QueryClient()"],
11+
"providers": [
12+
{
13+
"open": "<QueryClientProvider client={queryClient}>",
14+
"close": "</QueryClientProvider>"
15+
}
16+
]
17+
},
18+
"layout": {
19+
"imports": [
20+
"import { SolidQueryDevtools } from '@tanstack/solid-query-devtools'"
21+
],
22+
"jsx": "<SolidQueryDevtools buttonPosition='bottom-right' />"
23+
},
24+
"routes": [
25+
{
26+
"url": "/demo/tanstack-query",
27+
"name": "TanStack Query"
28+
}
29+
]
30+
}

0 commit comments

Comments
 (0)