Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

App.jsx

22 lines532 Bytes

1import { Match, Switch } from 'solid-js'
2import { createQuery } from '@tanstack/solid-query'
3​
4const App = () => {
5 const query = createQuery(() => ({
6 queryKey: ['test'],
7 queryFn: async () => {
8 await new Promise((r) => setTimeout(r, 1000))
9 return 'Success'
10 },
11 }))
12​
13 return (
14 <Switch>
15 <Match when={query.isPending}>Loading...</Match>
16 <Match when={query.isError}>An error has occurred!</Match>
17 <Match when={query.isSuccess}>{query.data}</Match>
18 </Switch>
19 )
21​
22export default App