metropolitan-bronze
metropolitan-bronzeβ€’16mo ago

useParams, useResource giving different results in different context.

I tried to get the resourceName, actions, params by using one of this hook inside react-router-v6 routerProvider component and in routeChangeHandler. But they are giving different results. In routerPorvider I got excepted result from this {resource, action, id} = useParams(); // {resouce: 'post', action: 'edit', id: 2}. But in routeChangeHanlder, I got {resource: 'post/edit/2', action: undefined, id: undefined}. why?
9 Replies
refine-support-bot
refine-support-botβ€’16mo ago
Hi, I am refine support bot :wave:. I am here to help you with your question. I searched for the answer to your question in the refine documentation and found an answer! πŸ†
Answer: useResource returns the resource object, resourceName and query params id and action. It can be used to get the resource object by name or route name. SOURCES: ./docs/api-reference/core/hooks/resource/useResource.md

Note: If this is the answer you need, then we are very lucky. If not, please wait for someone from the refine core team or the community to try to help you.
conscious-sapphire
conscious-sapphireβ€’16mo ago
Hello @sebabratakundu, can you provide a reproducible example, it's hard to tell without details. Best
metropolitan-bronze
metropolitan-bronzeβ€’16mo ago
I just console log the useParams() hook result in both of the components. inside RouteChangeHandler and react-router-v6/src/routerProvider.txt -> ResourceComponent components.
metropolitan-bronze
metropolitan-bronzeβ€’16mo ago
I am working on the dynamic title feature of refine. https://github.com/refinedev/refine/issues/2810
GitHub
[FEAT] Dynamic window title Β· Issue #2810 Β· refinedev/refine
Is your feature request related to a problem? Please describe. It would be great if each page could have an auto-generated and custom title. Example, For the Posts resource dashboard -> Dash...
metropolitan-bronze
metropolitan-bronzeβ€’16mo ago
@batuhanw any help?
extended-salmon
extended-salmonβ€’16mo ago
Hey @sebabratakundu, I'm investigating the issue πŸ€–
metropolitan-bronze
metropolitan-bronzeβ€’16mo ago
Hi @aliemirs , did you find any possible reason for this?
conscious-sapphire
conscious-sapphireβ€’16mo ago
@sebabratakundu We haven't found the reason yet, but we are on it. Sorry for the delay πŸ™
metropolitan-bronze
metropolitan-bronzeβ€’16mo ago
NP πŸ‘