Skip to content

Commit 8f0d834

Browse files
theVedantaTkDodoautofix-ci[bot]
authored
feat: Preact Adapter (#9935)
* initial setup -- duplicated + package.json edited * simple preact updations * missed a React.ReactNode * testing grunt work (preact library + other small issues + ErrorBoundary custom implementation) * missed a few * Adds ErrorBoundary (from react-error-boundary, but scaled down for preact) -- fixes a lot of tests, which expect react-related functionality * useSuspenseQueries left -- removed the useQuery.promise tests * forgot the console logs * useSuspenseQueries 2 resolved; tests done * ci: apply automated fixes * fix: example * fix: configs should be symlinks * fix: sync versions for npm-run-all2 * ref: re-sync runall2 * ref: go back to 5.0.0 * ref: remove changelog * react-query -> preact-query * remove use client directive + added the useSyncExternalStore (decoupled from compat) * remove the react remnants * generate docs * typescript eslint * docs * vite config fix * docs now reference react docs (most of them atleast) * code-rabbit issues addressed * <div/> lol * fix: docs * ci: apply automated fixes * fix: lockfile * fix: duplicated versions * lockfile (I cooked or am I cooked) * ci: apply automated fixes * Making small edits to fix versioning, warnings, and lock * unhandled error compat * Fixing CI * Fixed the CI errors * ci: apply automated fixes * Prettier format * Update changeset for Preact Adapter feature --------- Co-authored-by: TkDodo <office@dorfmeister.cc> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent d688458 commit 8f0d834

File tree

197 files changed

+34962
-8498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+34962
-8498
lines changed

.changeset/olive-rats-yawn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tanstack/preact-query": minor
3+
---
4+
5+
feat: Preact Adapter

docs/config.json

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,31 @@
167167
"to": "framework/angular/zoneless"
168168
}
169169
]
170+
},
171+
{
172+
"label": "preact",
173+
"children": [
174+
{
175+
"label": "Overview",
176+
"to": "framework/preact/overview"
177+
},
178+
{
179+
"label": "Installation",
180+
"to": "framework/preact/installation"
181+
},
182+
{
183+
"label": "Quick Start",
184+
"to": "framework/preact/quick-start"
185+
},
186+
{
187+
"label": "TypeScript",
188+
"to": "framework/preact/typescript"
189+
},
190+
{
191+
"label": "GraphQL",
192+
"to": "framework/preact/graphql"
193+
}
194+
]
170195
}
171196
]
172197
},
@@ -717,6 +742,131 @@
717742
"to": "framework/angular/guides/does-this-replace-client-state"
718743
}
719744
]
745+
},
746+
{
747+
"label": "preact",
748+
"children": [
749+
{
750+
"label": "Important Defaults",
751+
"to": "framework/preact/guides/important-defaults"
752+
},
753+
{
754+
"label": "Queries",
755+
"to": "framework/preact/guides/queries"
756+
},
757+
{
758+
"label": "Query Keys",
759+
"to": "framework/preact/guides/query-keys"
760+
},
761+
{
762+
"label": "Query Functions",
763+
"to": "framework/preact/guides/query-functions"
764+
},
765+
{
766+
"label": "Query Options",
767+
"to": "framework/preact/guides/query-options"
768+
},
769+
{
770+
"label": "Network Mode",
771+
"to": "framework/preact/guides/network-mode"
772+
},
773+
{
774+
"label": "Parallel Queries",
775+
"to": "framework/preact/guides/parallel-queries"
776+
},
777+
{
778+
"label": "Dependent Queries",
779+
"to": "framework/preact/guides/dependent-queries"
780+
},
781+
{
782+
"label": "Background Fetching Indicators",
783+
"to": "framework/preact/guides/background-fetching-indicators"
784+
},
785+
{
786+
"label": "Window Focus Refetching",
787+
"to": "framework/preact/guides/window-focus-refetching"
788+
},
789+
{
790+
"label": "Disabling/Pausing Queries",
791+
"to": "framework/preact/guides/disabling-queries"
792+
},
793+
{
794+
"label": "Query Retries",
795+
"to": "framework/preact/guides/query-retries"
796+
},
797+
{
798+
"label": "Paginated Queries",
799+
"to": "framework/preact/guides/paginated-queries"
800+
},
801+
{
802+
"label": "Infinite Queries",
803+
"to": "framework/preact/guides/infinite-queries"
804+
},
805+
{
806+
"label": "Initial Query Data",
807+
"to": "framework/preact/guides/initial-query-data"
808+
},
809+
{
810+
"label": "Placeholder Query Data",
811+
"to": "framework/preact/guides/placeholder-query-data"
812+
},
813+
{
814+
"label": "Mutations",
815+
"to": "framework/preact/guides/mutations"
816+
},
817+
{
818+
"label": "Query Invalidation",
819+
"to": "framework/preact/guides/query-invalidation"
820+
},
821+
{
822+
"label": "Invalidation from Mutations",
823+
"to": "framework/preact/guides/invalidations-from-mutations"
824+
},
825+
{
826+
"label": "Updates from Mutation Responses",
827+
"to": "framework/preact/guides/updates-from-mutation-responses"
828+
},
829+
{
830+
"label": "Optimistic Updates",
831+
"to": "framework/preact/guides/optimistic-updates"
832+
},
833+
{
834+
"label": "Query Cancellation",
835+
"to": "framework/preact/guides/query-cancellation"
836+
},
837+
{
838+
"label": "Scroll Restoration",
839+
"to": "framework/preact/guides/scroll-restoration"
840+
},
841+
{
842+
"label": "Filters",
843+
"to": "framework/preact/guides/filters"
844+
},
845+
{
846+
"label": "Performance & Request Waterfalls",
847+
"to": "framework/preact/guides/request-waterfalls"
848+
},
849+
{
850+
"label": "Prefetching & Router Integration",
851+
"to": "framework/preact/guides/prefetching"
852+
},
853+
{
854+
"label": "Caching",
855+
"to": "framework/preact/guides/caching"
856+
},
857+
{
858+
"label": "Render Optimizations",
859+
"to": "framework/preact/guides/render-optimizations"
860+
},
861+
{
862+
"label": "Default Query Fn",
863+
"to": "framework/preact/guides/default-query-function"
864+
},
865+
{
866+
"label": "Does this replace [Redux, MobX, etc]?",
867+
"to": "framework/preact/guides/does-this-replace-client-state"
868+
}
869+
]
720870
}
721871
]
722872
},
@@ -1009,6 +1159,91 @@
10091159
"to": "framework/angular/reference/functions/injectMutation"
10101160
}
10111161
]
1162+
},
1163+
{
1164+
"label": "preact",
1165+
"children": [
1166+
{
1167+
"label": "useQuery",
1168+
"to": "framework/preact/reference/functions/useQuery"
1169+
},
1170+
{
1171+
"label": "useQueries",
1172+
"to": "framework/preact/reference/functions/useQueries"
1173+
},
1174+
{
1175+
"label": "useInfiniteQuery",
1176+
"to": "framework/preact/reference/functions/useInfiniteQuery"
1177+
},
1178+
{
1179+
"label": "useMutation",
1180+
"to": "framework/preact/reference/functions/useMutation"
1181+
},
1182+
{
1183+
"label": "useIsFetching",
1184+
"to": "framework/preact/reference/functions/useIsFetching"
1185+
},
1186+
{
1187+
"label": "useIsMutating",
1188+
"to": "framework/preact/reference/functions/useIsMutating"
1189+
},
1190+
{
1191+
"label": "useMutationState",
1192+
"to": "framework/preact/reference/functions/useMutationState"
1193+
},
1194+
{
1195+
"label": "useSuspenseQuery",
1196+
"to": "framework/preact/reference/functions/useSuspenseQuery"
1197+
},
1198+
{
1199+
"label": "useSuspenseInfiniteQuery",
1200+
"to": "framework/preact/reference/functions/useSuspenseInfiniteQuery"
1201+
},
1202+
{
1203+
"label": "useSuspenseQueries",
1204+
"to": "framework/preact/reference/functions/useSuspenseQueries"
1205+
},
1206+
{
1207+
"label": "QueryClientProvider",
1208+
"to": "framework/preact/reference/functions/QueryClientProvider"
1209+
},
1210+
{
1211+
"label": "useQueryClient",
1212+
"to": "framework/preact/reference/functions/useQueryClient"
1213+
},
1214+
{
1215+
"label": "queryOptions",
1216+
"to": "framework/preact/reference/functions/queryOptions"
1217+
},
1218+
{
1219+
"label": "infiniteQueryOptions",
1220+
"to": "framework/preact/reference/functions/infiniteQueryOptions"
1221+
},
1222+
{
1223+
"label": "mutationOptions",
1224+
"to": "framework/preact/reference/functions/mutationOptions"
1225+
},
1226+
{
1227+
"label": "usePrefetchQuery",
1228+
"to": "framework/preact/reference/functions/usePrefetchQuery"
1229+
},
1230+
{
1231+
"label": "usePrefetchInfiniteQuery",
1232+
"to": "framework/preact/reference/functions/usePrefetchInfiniteQuery"
1233+
},
1234+
{
1235+
"label": "QueryErrorResetBoundary",
1236+
"to": "framework/preact/reference/functions/QueryErrorResetBoundary"
1237+
},
1238+
{
1239+
"label": "useQueryErrorResetBoundary",
1240+
"to": "framework/preact/reference/functions/useQueryErrorResetBoundary"
1241+
},
1242+
{
1243+
"label": "hydration",
1244+
"to": "framework/react/reference/functions/HydrationBoundary"
1245+
}
1246+
]
10121247
}
10131248
]
10141249
},

docs/framework/angular/guides/infinite-queries.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,20 @@ export class Example {
5151
```angular-html
5252
<div>
5353
@if (query.isPending()) {
54-
<p>Loading...</p>
54+
<p>Loading...</p>
5555
} @else if (query.isError()) {
56-
<span>Error: {{ query?.error().message }}</span>
57-
} @else { @for (page of query?.data().pages; track $index) { @for (project of
58-
page.data; track project.id) {
59-
<p>{{ project.name }} {{ project.id }}</p>
60-
} }
61-
<div>
62-
<button (click)="query.fetchNextPage()" [disabled]="nextButtonDisabled()">
63-
{{ nextButtonText() }}
64-
</button>
65-
</div>
56+
<span>Error: {{ query?.error().message }}</span>
57+
} @else {
58+
@for (page of query?.data().pages; track $index) {
59+
@for (project of page.data; track project.id) {
60+
<p>{{ project.name }} {{ project.id }}</p>
61+
}
62+
}
63+
<div>
64+
<button (click)="query.fetchNextPage()" [disabled]="nextButtonDisabled()">
65+
{{ nextButtonText() }}
66+
</button>
67+
</div>
6668
}
6769
</div>
6870
```

docs/framework/angular/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ import { lastValueFrom } from 'rxjs'
8484
<strong>✨ {{ data.stargazers_count }}</strong>
8585
<strong>🍴 {{ data.forks_count }}</strong>
8686
}
87-
`
87+
`,
8888
})
8989
export class SimpleExampleComponent {
9090
http = inject(HttpClient)

docs/framework/angular/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import { lastValueFrom } from 'rxjs'
5151
import {
5252
injectMutation,
5353
injectQuery,
54-
QueryClient
54+
QueryClient,
5555
} from '@tanstack/angular-query-experimental'
5656
5757
@Component({

docs/framework/angular/typescript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class MyComponent {
7878
template: `
7979
@if (query.isSuccess()) {
8080
@let data = query.data();
81-
// ^? data: number
81+
// ^? data: number
8282
}
8383
`,
8484
})
@@ -104,7 +104,7 @@ class MyComponent {
104104
class MyComponent {
105105
query = injectQuery(() => ({
106106
queryKey: ['groups'],
107-
queryFn: fetchGroups
107+
queryFn: fetchGroups,
108108
}))
109109
}
110110
```

docs/framework/preact/graphql.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
id: graphql
3+
title: GraphQL
4+
ref: docs/framework/react/graphql.md
5+
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
6+
---
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
id: background-fetching-indicators
3+
title: Background Fetching Indicators
4+
ref: docs/framework/react/guides/background-fetching-indicators.md
5+
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
6+
---
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
id: caching
3+
title: Caching Examples
4+
ref: docs/framework/react/guides/caching.md
5+
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
6+
---
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
id: default-query-function
3+
title: Default Query Function
4+
ref: docs/framework/react/guides/default-query-function.md
5+
replace: { 'React': 'Preact', 'react-query': 'preact-query' }
6+
---

0 commit comments

Comments
 (0)