I have the following nest route:
createRoutesFromElements(<>
<Route path="/:siteid/:route?/login/:cmd?/:id?" element={< LoginLayout/>}>
<Route ... />
<Route ... />
<Route path="/:siteid/:route?/login/:cmd?/:id?" element={< LoginPage />} />
</Route>
<Route...more routes />
</>)
)
But I get the following error:
Absolute route path "/:siteid/:route/login/:cmd" nested under path "/:siteid/:route/login/:cmd/:id" is not valid.
Just to clarify what I am trying to do – I have several different ways to get to the same login…I just want them all routed to the same place:
e.g.:
/siteid/login
/siteid/route/login
/siteid/route/login/forgot
/siteid/login/reset/1123
are some examples
Still fairly new on the options ans splats. Any help would be great.
2
Answers
Try below code. I hope this will work.
<Route path="/" element={< LoginLayout/>}>
this is the root. In the propspath
what ever you put will be starting of all the sub route you are adding in side the root route.#HappyCoding
You can make the
LoginPage
rendered on the layout route’s index route, i.e. matched and rendered when the path is the layout route’s path.