You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/routes/solid-start/building-your-application/data-loading.mdx
+5-7
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ It takes an async function and returns a [signal](/reference/basic-reactivity/cr
14
14
15
15
<TabsCodeBlocks>
16
16
<divid="ts">
17
-
```tsx {6-9}
17
+
```tsx {6-9} title="/src/routes/users.tsx"
18
18
import { For, createResource } from"solid-js";
19
19
20
20
typeUser= { name:string; house:string };
@@ -30,7 +30,7 @@ export default function Page() {
30
30
```
31
31
</div>
32
32
<divid="js">
33
-
```tsx {4-7}
33
+
```tsx {4-7} title="/src/routes/users.jsx"
34
34
import { For, createResource } from"solid-js";
35
35
36
36
exportdefaultfunction Page() {
@@ -46,11 +46,8 @@ export default function Page() {
46
46
</TabsCodeBlocks>
47
47
48
48
When fetching inside components, you can encounter unnecessary waterfalls, especially when nested under lazy loaded sections.
49
-
To solve this, it can be valuable to introduce a hoist and cache mechanism.
50
-
51
-
Using a library like [Tanstack Query](https://tanstack.com/query/latest) can help with this.
52
-
53
-
for the example below we will be using the data in APIs in [`solid-router`](/solid-router)
49
+
To solve this, it is recommended to hoist the data fetching to the top of the component tree or, when in [SolidStart](/solid-start), use the server to fetch data in a non-blocking way.
50
+
For the example below we will be using the data in APIs in [`solid-router`](/solid-router)
54
51
55
52
Using some of the features of `solid-router`, we can create a cache for our data:
56
53
@@ -78,6 +75,7 @@ export default function Page() {
0 commit comments