Open History to see the last commit
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>
21}
22β
23export default App