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

App.tsx

23 lines427 Bytes

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