Skip to content

Redirect with useRoutes #151

Answered by ryansolid
outbackStack asked this question in Q&A
Discussion options

You must be logged in to vote

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 use component instead of element.

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 /> },
          }
      ]
    }
]

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@outbackStack
Comment options

Answer selected by outbackStack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants