foreign-sapphire
foreign-sapphire16mo ago

Avoid resource loading

hey guys, I have that routes. when I navigate to list, my list component call a different resource of vertical-contest-notice , but refine call both. Is there a way to avoid to call vertical-contest-notice as resource, keep the behaviour only for component routing. I'm using nextjs.
No description
8 Replies
kapa.ai
kapa.ai16mo ago
Hi @mandado. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
kapa.ai
kapa.ai16mo ago
---------------------- Based on the information extracts provided, you can override the default resource value used by the hooks in your list component by passing the resource prop to the hook. This way, you can specify a different resource for your list component without affecting the routing behavior. Here's an example of how to do this in your list component:
import { useTable } from "@refinedev/core";

const PostList: React.FC = () => {
const result = useTable({
resource: "users", // Replace "users" with the desired resource
});

return <div>...</div>;
};
import { useTable } from "@refinedev/core";

const PostList: React.FC = () => {
const result = useTable({
resource: "users", // Replace "users" with the desired resource
});

return <div>...</div>;
};
This will make your list component call the specified resource instead of the default vertical-contest-notice resource. However, this solution assumes you're using the useTable hook in your list component. If you're using a different hook or component, you may need to adjust the code accordingly. For more information on overriding the default resource value, refer to this source (https://refine.dev/docs/api-reference/general-concepts#the-resource-value-is-determined-from-the-resource-prop-of-the-hook). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
General Concepts | refine
- refine core is fully independent of UI. So you can use core components and hooks without any UI dependency.
kapa.ai
kapa.ai16mo ago
<@121754827691786243> kapa.ai is still learning and improving, please let us how it did by reacting below
correct-apricot
correct-apricot16mo ago
if i understand correctly, bot is right. you can replace resource on any data hook
foreign-sapphire
foreign-sapphire16mo ago
The problem is when I click on sidebar, refine make two requests one for vertical-constest-notice defined on resources and other for my custom resource, I want to avoid the first request
correct-apricot
correct-apricot16mo ago
hmm. if you don't use any data hook, request will not send. and what do you mean by "custom resource" ? can you reproduce the problem on codesandbox or any other platform please ? i will happy to debug
foreign-sapphire
foreign-sapphire16mo ago
is there a way to define my routes and show links on sidebar without using resources with nextjs ?
correct-apricot
correct-apricot16mo ago
yes, you can use this. if you are using themed layout, usages are the same https://refine.dev/docs/faq/#how-can-i-add-an-item-to-the-sider-component