-
I'm using it this way to have different queryClients for different clients. export const createQueryClient = () =>
new QueryClient({
queryCache: new QueryCache({
onError: (error) => {
console.error(error);
},
}),
defaultOptions: {
queries: {
useErrorBoundary: true,
refetchOnWindowFocus: false,
},
mutations: {
useErrorBoundary: true,
},
},
});
export const getServerSideProps: GetServerSideProps = async (ctx) => {
const queryClient = createQueryClient();
return {
props: {
dehydratedState: JSON.parse(JSON.stringify(dehydrate(queryClient))),
},
};
}; If it weren't for SSR, I could simply create a global queryClient and use that I want to use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
not sure if a zustand store should be coupled to a queryClient, but if you want that, you need to wrap zustand with zutand/context and pass the queryClient to it as a "prop" |
Beta Was this translation helpful? Give feedback.
not sure if a zustand store should be coupled to a queryClient, but if you want that, you need to wrap zustand with zutand/context and pass the queryClient to it as a "prop"
https://github.com/pmndrs/zustand#react-context