Open
Description
Description
I'm trying out openapi-react-query and I don't seem to be able to get it to work. I'm creating a client like so:
const fetchClient = createFetchClient<paths>({
baseUrl: "http://localhost:8880"
});
export const $api = createClient(fetchClient);
...and then using it in a component like so:
const { data, isLoading } = $api.useQuery("get", "/query", {
params: {
query: {
player: false,
playlists: false,
playlistItems: true,
plref: playlistId,
plrange: '0:100000',
// @ts-expect-error LibraryColumns is readonly
plcolumns: LibraryColumns
}
}
});
However, when I run this in the browser, I get the following error message:
openapi-react-query.js?v=2cd51558:985 Uncaught Error: No QueryClient set, use QueryClientProvider to set one
at useQueryClient (openapi-react-query.js?v=2cd51558:985:11)
at useBaseQuery (openapi-react-query.js?v=2cd51558:1080:18)
at useQuery (openapi-react-query.js?v=2cd51558:1151:10)
at Object.useQuery (openapi-react-query.js?v=2cd51558:1234:66)
at FoobarLibrary (foobarLibrary.tsx:143:38)
at renderWithHooks (react-dom_client.js?v=a0b8382c:11548:26)
at mountIndeterminateComponent (react-dom_client.js?v=a0b8382c:14926:21)
at beginWork (react-dom_client.js?v=a0b8382c:15914:22)
at HTMLUnknownElement.callCallback2 (react-dom_client.js?v=a0b8382c:3674:22)
at Object.invokeGuardedCallbackDev (react-dom_client.js?v=a0b8382c:3699:24)
I've been reading online about react-query and it seems you need to add a QueryClientProvider around your app, but I'm not sure how to do that.
Proposal
If someone can help me fix this I will contribute to the docs and add a more helpful error message so that others don't have this issue.
Checklist
- I’m willing to open a PR for this (see CONTRIBUTING.md)