vicious-gold
vicious-gold3y ago

custom route element not visible

{ element:<div> <LayoutWrapper>sssshhhhh</LayoutWrapper> </div>, path:"/sample",

} this is my custom route and i want show this page after i click button http://localhost:3000/appointment/sample this way i want url
16 Replies
vicious-gold
vicious-goldOP3y ago
the problem is i want to show this in particular appointment resource
provincial-silver
provincial-silver3y ago
Does this work when you update the path like appointment/sample?
vicious-gold
vicious-goldOP3y ago
it shows 404 error page
vicious-gold
vicious-goldOP3y ago
this one
No description
vicious-gold
vicious-goldOP3y ago
this page is visible when i provide it in url
provincial-silver
provincial-silver3y ago
Checking now, give me couple minutes and we will figure out a way
vicious-gold
vicious-goldOP3y ago
okay
provincial-silver
provincial-silver3y ago
Ali Emir Şen
StackBlitz
Refine Antd Example (forked) - StackBlitz
Run official live example code for Refine Antd, created by Pankod on StackBlitz
provincial-silver
provincial-silver3y ago
Checkout this example there's a resource posts and added a custom route under posts/custom-route Works just fine
vicious-gold
vicious-goldOP3y ago
okay ill check how r routing to this route for example using push?
Omer
Omer3y ago
You can use useNavigation hook for redirect
import {
useNavigation,
} from "@pankod/refine-core";
const { push } = useNavigation();

push("/posts/custom-route")
import {
useNavigation,
} from "@pankod/refine-core";
const { push } = useNavigation();

push("/posts/custom-route")
https://refine.dev/docs/api-reference/core/hooks/navigation/useNavigation/#push-replace-and-goback
provincial-silver
provincial-silver3y ago
Refine Antd Example (forked) - StackBlitz
Run official live example code for Refine Antd, created by Pankod on StackBlitz
vicious-gold
vicious-goldOP3y ago
but the highligted part in the sider is not getting highlighted when it navigates to custom route page . for example post resource in sider is not getting highlighted when it is custom route
vicious-gold
vicious-goldOP3y ago
please check here
provincial-silver
provincial-silver3y ago
You are using a custom sider right? You can add this key by checking the location.pathname (can be accessed via window or useLocation from useRouterContext which is exported from refine-core) Something like this;
const { useLocation } = useRouterContext();
const { pathname } = useLocation();

const keysFromPath = pathname.split(/\//).filter((el) => el);


return (<Menu selectedKeys={[...selectedKeys, ...keysFromPath]} {...} />
const { useLocation } = useRouterContext();
const { pathname } = useLocation();

const keysFromPath = pathname.split(/\//).filter((el) => el);


return (<Menu selectedKeys={[...selectedKeys, ...keysFromPath]} {...} />
vicious-gold
vicious-goldOP3y ago
i am using custom sider . i tried this but it is not working ...