@tanstack/solid-query 4.10.3 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Tanner Linsley
3
+ Copyright (c) 2021-present Tanner Linsley
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-query",
3
- "version": "4.10.3",
3
+ "version": "4.11.0",
4
4
  "description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "@tanstack/query-core": "4.10.3"
41
41
  },
42
42
  "peerDependencies": {
43
- "solid-js": "^1.5.4"
43
+ "solid-js": "^1.5.7"
44
44
  },
45
45
  "peerDependenciesMeta": {},
46
46
  "scripts": {
@@ -0,0 +1,58 @@
1
+ import { fireEvent, render, screen, waitFor } from 'solid-testing-library'
2
+
3
+ import { createSignal, Show, startTransition, Suspense } from 'solid-js'
4
+ import { createQuery, QueryCache, QueryClientProvider } from '..'
5
+ import { createQueryClient, queryKey, sleep } from './utils'
6
+
7
+ describe("useQuery's in Suspense mode with transitions", () => {
8
+ const queryCache = new QueryCache()
9
+ const queryClient = createQueryClient({ queryCache })
10
+
11
+ it('should render the content when the transition is done', async () => {
12
+ const key = queryKey()
13
+
14
+ function Suspended() {
15
+ const state = createQuery(key, async () => {
16
+ await sleep(10)
17
+ return true
18
+ })
19
+
20
+ return <Show when={state.data}>Message</Show>
21
+ }
22
+
23
+ function Page() {
24
+ const [showSignal, setShowSignal] = createSignal(false)
25
+
26
+ return (
27
+ <div>
28
+ <button
29
+ aria-label="toggle"
30
+ onClick={() =>
31
+ startTransition(() => setShowSignal((value) => !value))
32
+ }
33
+ >
34
+ {showSignal() ? 'Hide' : 'Show'}
35
+ </button>
36
+ <Suspense fallback="Loading">
37
+ <Show when={showSignal()}>
38
+ <Suspended />
39
+ </Show>
40
+ </Suspense>
41
+ </div>
42
+ )
43
+ }
44
+
45
+ render(() => (
46
+ <QueryClientProvider client={queryClient}>
47
+ <Page />
48
+ </QueryClientProvider>
49
+ ))
50
+
51
+ await waitFor(() => screen.getByText('Show'))
52
+ fireEvent.click(screen.getByLabelText('toggle'))
53
+
54
+ await waitFor(() => screen.getByText('Message'))
55
+ // verify that the button also updated. See https://github.com/solidjs/solid/issues/1249
56
+ await waitFor(() => screen.getByText('Hide'))
57
+ })
58
+ })