Before upgrading to v6 I had this part of code, which worked as it should:
//before
return (
<BrowserRouter>
<Route render={(props) => (
<div className={`layout ${themeReducer.mode}`}>
<Sidebar {...props}/>
<div className="layout__content">
<TopNav/>
<div className="layout__content-main">
<Switch>
<Route path='/' exact component={Dashboard} />
<Route path='/activity' component={Activity} />
</Switch>
</div>
</div>
</div>
)}/>
</BrowserRouter>
)
After upgrading I only changed Switch
to Routes
and component
to element
and expected it to work, but it didn't.
Error: A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.
Tried many things, but nothing helped. How can I make it work the way it worked before the upgrading?
//after
return (
<BrowserRouter>
<Route render={(props) => (
<div className={`layout ${themeReducer.mode}`}>
<Sidebar {...props}/>
<div className="layout__content">
<TopNav/>
<div className="layout__content-main">
<Routes>
<Route path='/' element={<Dashboard/>} />
<Route path='/activity' element={<Activity/>} />
</Routes>
</div>
</div>
</div>
)}/>
</BrowserRouter>
)