I am working on a reactjs project where I utilize react-router. I have multiple components to render, but not sure how to structure it. I am not getting expected results
Components
- Authentication
- SideBar
- List
- Detail
App.js
import .....
.... //some import statements
function App(){
<BrowserRouter>
<SideBar/>
<Routes>
<Route path="/" element={<List/>}/>
<Route path="/detail" element={<Detail/>}/>
<Route path="/authentication" element={<Authentication/>}/>
</Routes>
</BrowserRouter>
}
Here I have totally 4 components. The sidebar component will be common for both Detail and List component, & I don't want it to be visible for Authentication component.
Tried using the Outlet
App.js
import .....
.... //some import statements
function App(){
<BrowserRouter>
<Routes>
<Route path="/" element={<Authentication/>}/>
<Route path="/app" element={<Container/>}/>
</Routes>
</BrowserRouter>
}
Container.js
import .....
.... //some import statements
function Container(){
<SideBar/>
<Routes>
<Route path="/list" element={<List/>}/>
<Route path="/detail" element={<Detail/>}/>
</Routes>
}
Now the issue is when I navigate to http:///app it is showing a blank page with sidebar, which doesn't serve a purpose.
How this can be achieved ?