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