我已经将<ReactQueryDevtools />
打包到<QueryClientProvider>
中,所以我不明白为什么会遇到这个问题?
我已经看过TanStack Query文档,我不明白这个问题。
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import { BrowserRouter } from 'react-router-dom';
import { worker } from '@uidotdev/react-query-api';
import { QueryClient, QueryClientProvider } from 'react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
const queryClient = new QueryClient();
new Promise((res) => setTimeout(res, 100))
.then(() =>
worker.start({
quiet: true,
onUnhandledRequest: 'bypass',
})
)
.then(() => {
ReactDOM.render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<BrowserRouter>
<div className="container">
<App />
</div>
</BrowserRouter>
<ReactQueryDevtools />
</QueryClientProvider>
</React.StrictMode>,
document.getElementById('root')
);
});
我的主机:
Error: No QueryClient set, use QueryClientProvider to set one
1条答案
按热度按时间g6ll5ycj1#
其中一个导入不正确
应该是