我的代码如下所示:
import { useQuery, QueryClientProvider, QueryClient } from 'react-query'
import React from 'react'
const queryClient = new QueryClient()
const fetchData = async () => {
return (await fetch(`http://jservice.io/api/random?count=50`)).json()
}
function App() {
const [isLoading, error, data] = useQuery('qa', fetchData)
console.log(data)
return (
<QueryClientProvider client={queryClient}>
<div className="App">
</div>
</QueryClientProvider>
);
}
export default App;
我已经使用了 React Query v3 中的确切示例并且仍然得到
Error: No QueryClient set, use QueryClientProvider to set one
我正处于完全放弃图书馆并求助于替代品的边缘。