I am building a react app and have react-router v6 installed. My challenge is switching between components within a parent component. My structure is as follows.
App.js -> Rootpage.js -> AuthPage.js -> (Register.js | SignIn.js | PasswordRecover.js)
The RootPage is where I want to nest various other parts of the app like Dashboard, UserList etc.
The AuthPage should be able to switch between SignIn, Register and PasswordRecover depending on the route. I have tried the following code on my Auth page
<div className="auth">
<div className="auth-left">
<Routes>
<Route path='/signin' element = { <SignIn /> } />
<Route path='/signup' element = { <SignUp /> } />
<Route path='/recovery' element = { <PasswordRecovery /> } />
</Routes>
</div>
<div className="auth-right">
<img src="./assets/image.png" alt="" />
</div>
</div>
and this on my RootPage
<div className='root-page'>
<Routes>
<Route path='/' element = { <Auth /> } />
</Routes>
</div>
Nothing seems to work. With v5 I would simply use switch and it would work.
Anyone know how to work this out?
Thanks.