My error: No routes matched location "/" history.ts:487
<Route render={(history) => <Search history={history}/>}></Route>
<Routes>
<Route render={(history) => <Search history={history} />}></Route>
</Routes>
My error: No routes matched location "/" history.ts:487
<Route render={(history) => <Search history={history}/>}></Route>
<Routes>
<Route render={(history) => <Search history={history} />}></Route>
</Routes>
2
Answers
I'm fixed and we don't need history mode. We will use useNavigate instead history.push So code after fixed is :
In
react-router-dom@6
theRoute
component renders all content on a singleelement
prop taking aReact.ReactNode
, i.e. JSX.render
is an older RRDv5 prop.The
Route
also needs apath
if it isn’t rendering anOutlet
(i.e. for nested routes) and needs to participate in route path matching. A root"/"
path is required, or a "catch-all"path="*"
route needs to also be rendered.Example:
I suspect you are migrating from
react-router@5
and were trying to pass/forward the old v5 route props which don’t exist in v6. Use the appropriate React hooks in the routed component instead. Instead of ahistory
object exposed via auseHistory
hook in RRDv5, anavigate
function viauseNavigate
hook replaced it.Example: