Answer the question
In order to leave comments, you need to log in
How in the route, if one url path is given, add an additional path to it?
The bottom line is, is there a <Route path="/first" component={first} />
way to make it so that when switching to /first , /item1 is automatically added, that is, the general path automatically becomes /first/item1? All options are interesting.
Thank you!
Answer the question
In order to leave comments, you need to log in
There are several options, but as I see it, it is best to think through the architecture correctly.
When you go to /first, you probably open some kind of container in which other routes are located (/first/item1, /first/item2 etc)
An automatic redirect can be done in the First component, where you describe nested routes
<Switch>
<Redirect
from={"/first"}
exact
to={"/first/item1"}
render={() => <Item {...props}/>}
/>
<Route
path={"/first/item1"}
render={() => <Item {...props}/>}
/>
<Route
path={ '/first/item2'}
render={() => <List {...props}/>}
/>
</Switch>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question