stormy-gold
stormy-goldβ€’2y 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β€’2y 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.
mute-gold
mute-goldβ€’2y ago
Hello @sebabratakundu, can you provide a reproducible example, it's hard to tell without details. Best
stormy-gold
stormy-goldβ€’2y 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.
stormy-gold
stormy-goldβ€’2y 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...
stormy-gold
stormy-goldβ€’2y ago
@batuhanw any help?
adverse-sapphire
adverse-sapphireβ€’2y ago
Hey @sebabratakundu, I'm investigating the issue πŸ€–
stormy-gold
stormy-goldβ€’2y ago
Hi @aliemirs , did you find any possible reason for this?
mute-gold
mute-goldβ€’2y ago
@sebabratakundu We haven't found the reason yet, but we are on it. Sorry for the delay πŸ™
stormy-gold
stormy-goldβ€’2y ago
NP πŸ‘