Answer the question
In order to leave comments, you need to log in
How to do redirect with react-router without JSX?
There is a router configuration described as a JS object (not JSX).
Each element of the configuration array is essentially a Route object.
There is a path /account and its child paths: /account/profile, /account/password, etc.
I would like: so that when you go to /account, /account/profile is automatically included.
If I had used JSX I would have inserted a Redirect object, but JSX is not here because Lazy loading of components is needed.
...
{
path: 'account',
component: /* ... */,
getChildRoutes(partialNextState, cb) {
return cb(null, [
{
path: 'profile',
component: /* ... */,
},
]
onEnter: (_, replace) => { if (_.location.pathname === '/account') { replace('/account/profile') } },
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question