Redirect with useRoutes #151
Answered
by
ryansolid
outbackStack
asked this question in
Q&A
-
Thank you for this amazing router. I'm in the process of moving over from React. Question: How could I redirect to a page with useRoutes? With react-router I could this. If you go to path "/" then it will redirect you to "/dashboard" const routes = [
{
path: "/",
element: <Layout />,
children: [
{ index: true, element: <Navigate to="/dashboard" /> },
{
path: "other",
element: <OtherPage />,
}
]
}
] |
Beta Was this translation helpful? Give feedback.
Answered by
ryansolid
Aug 7, 2022
Replies: 1 comment 1 reply
-
This won't work the way you thing it will because Solid doesn't use VDOM and the way compilation works. If you want to use However to get this to work simulating our JSX compilation I'd try: const routes = [
{
path: "/",
get element() { return <Layout /> },
children: [
{ path: "/", get element() { return <Navigate to="/dashboard" /> } },
{
path: "other",
get element() { return <OtherPage /> },
}
]
}
] |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
outbackStack
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This won't work the way you thing it will because Solid doesn't use VDOM and the way compilation works. If you want to use
useRoutes
typically don't use JSX. And usecomponent
instead ofelement
.However to get this to work simulating our JSX compilation I'd try: