resource.route is deprecated
My code is working however it gives me a warning that resource.route is depreciated. The comment says "please use action components and
getDefaultActionPath
. I didnt find that in the docs though. Can someone tell me how to get the route the correct way?9 Replies
Hi @zomh. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The
route
property in the resources
object of Refine is indeed deprecated. Instead of using route
, you should define paths by the actions of the resource.
For each action (like list
, create
, edit
, show
), you can either pass a component or an object with component
and path
properties. If you pass a component, the default path will be used. If you pass an object, you can customize the path of the action.
Here's an example of how you can define paths for your resource actions:
In this example, for the posts
resource, the list
action uses the PostList
component and the default path (/posts
). The create
action uses the PostCreate
component and the default path (/posts/create
). For the categories
resource, the list
action uses the CategoryList
component and the default path (/categories
), and the show
action uses the CategoryShow
component and a custom path (/categories/:id/details
).
The default paths are:
- list
: /resources
- create
: /resources/create
- edit
: /resources/edit/:id
- show
: /resources/show/:id
You can find more information about this in the Refine documentation (https://refine.dev/docs/api-reference/core/components/refine-config).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@240974567730970625> kapa.ai is still learning and improving, please let us how it did by reacting below
like-goldOP•2y ago
@kapa.ai i did define my routes as you mentioned. However i'd like to read the current route in a different component. I know i can use pathname from useparsed but that gives me the exact url i just want to know on which route the user currently is
Let me check the knowledge base for you. One moment! :books:
----------------------
You can use the
useParsed
hook from Refine to access the current resource
, action
, and id
inferred from the URL. This hook leverages the parse
method of the routerProvider
to provide these details.
Here's an example of how you can use it:
In this example, resource
is the active resource that is matched by the current route and the action definitions in the resources
array of the Refine
component. action
is the active action that is matched by the current route and the action definitions in the resources
array of the Refine
component. id
is the main parameter used by the refine in API interactions.
You can find more information about this in the Refine documentation (https://refine.dev/docs/api-reference/core/hooks/navigation/useParsed).
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@240974567730970625> kapa.ai is still learning and improving, please let us how it did by reacting below
like-goldOP•2y ago
Are you guys not answering anymore questions in here is it just the bot now? Didn't get any answer to my last 3 questions 🫥
Hey @zomh ,
We sometimes struggle to keep up with answering all the questions. Thank you for your understanding.
It appears that your Sider component is outdated. My suggestion is to upgrade your dependencies to the latest version (
npm run refine update
) and then include the latest version of Sider in your project using the swizzle
command (https://refine.dev/docs/packages/documentation/cli/#swizzle).
If you don't need to customize Sider, you can directly use it from the refine packages (https://refine.dev/docs/api-reference/mui/components/mui-themed-layout/)| refine
component from refine, defines the overall structure and layout of a web page.
CLI | refine
refine CLI is a command line application that allows you to interact with your refine project and perform some tasks. This includes creating a new resource, managing updates, swizzle components, and runs your project (build, start, dev).
Additionally, if you create a GitHub issue, it would give us an opportunity to make the deprecation message more explanatory. Thank you 🎯
like-goldOP•2y ago
Hello @Omer,
first of all thank you for answering all of my questions.
I have to admit that I was ( and am) very spoiled by the great support of the refine team.
I see refine is growing and so is the discord and the need for support. So i was just asking if you maybe swapped to bot only support which would have been understandable for me. I did not mean to imply any bad feelings about it whatsoever.
So thank you and the refine team