Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions docs/framework/solid/guides/suspense.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,24 @@ import { Suspense } from 'solid-js'

You can use async `suspense` function that is provided by `solid-query`.

```vue
<script>
import { defineComponent } from 'vue'
```tsx
import { useQuery } from '@tanstack/solid-query'

const todoFetcher = async () =>
await fetch('https://jsonplaceholder.cypress.io/todos').then((response) =>
response.json(),
)
export default defineComponent({
name: 'SuspendableComponent',
async setup() {
const { data, suspense } = useQuery(() => ['todos'], todoFetcher)
await suspense()

return { data }
},
})
</script>

function SuspendableComponent() {
const query = useQuery(() => ({
queryKey: ['todos'],
queryFn: todoFetcher,
}))

// Accessing query.data directly inside a <Suspense> boundary
// automatically triggers suspension until data is ready
return <div>Data: {JSON.stringify(query.data)}</div>
}
```

## Fetch-on-render vs Render-as-you-fetch
Expand Down