How to use only the CRUD data hooks (useCreate, useOne etc.) without the router ? #3255
-
The data hooks of Refine (such as But how to use the Could not find any example of how to integrate the For example, I tried to create a small const MyList = () => {
const { selectProps: categorySelectProps } = useSelect({ resource: "categories" });
return (
<div>
<pre>{JSON.stringify(categorySelectProps, null, 2)}</pre>
</div>
);
};
export const MyComponent = () => {
return (
<Refine
dataProvider={dataProvider("https://api.fake-rest.refine.dev")}>
<MyList />
</Refine>
);
}; The Next, tried to remove the Supplying the import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
const queryClient = new QueryClient();
const queryCtx = React.createContext(queryClient); // create some context and supply it manually below
export const MyComponent = () => {
const { selectProps: categorySelectProps } = useSelect({
resource: "categories", queryOptions: {context: queryCtx}
});
return (
<div>
<pre>{JSON.stringify(categorySelectProps, null, 2)}</pre>
</div>
);
};
export default MyComponent ; Even the below wrapper will not work, and the same error. export const MyComponent = () => {
return (
<QueryClientProvider client={queryClient}>
<MyList />
</QueryClientProvider>
);
}; Q: Any help on how to use the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @KrishnaPG, Thank you for your great question. Actually, what you want to do is not possible at the moment. The reason is that the refine hooks are depending on the some providers that are provided by the refine App component. But we are planning to make it possible in the future. This change will be part of the next major release of refine. I will keep you updated. 🚀 |
Beta Was this translation helpful? Give feedback.
Hello @KrishnaPG,
Thank you for your great question. Actually, what you want to do is not possible at the moment. The reason is that the refine hooks are depending on the some providers that are provided by the refine App component. But we are planning to make it possible in the future. This change will be part of the next major release of refine. I will keep you updated. 🚀