i have a React app that uses React Router v5 (although i think the question applies to v4,5, and 6).
Here is what I want to do: in App.js:
<Router>
<Route path='/main' component={Main}/>
<Route path='/admin' component={Admin}/>
</Router>
And then in Main.js I have 2 other routes:
const Main=()=> {
return (
<div className='some-special-styling-only-for-main'>
<Route path='/dashboard' component={Dashboard}/>
<Route path='/calculator' component={Calculator}/>
</div>
)
}
This works, but is there anything wrong with it and is it best practice? I am asking because I notice some other Routers like react-location do not allow this (you have to define all routes in one place). Also I've never seen anyone else do it after hours of researching online.