I've had a problem with migration between react-router-dom
v5 to v6. After update my package I do a few upgrades in the code. Below is my version of code in v5 and with v6 and also Routing
component which give me a problem.
v5
export default function App() {
return (
<div className="App">
<Switch>
<AppContextProvider>
<Routing />
</AppContextProvider>
</Switch>
</div>
);
}
v6
export default function App() {
return (
<div className="App">
<AppContextProvider>
<Routes>
<Routing />
</Routes>
</AppContextProvider>
</div>
);
}
<Routing />
component
const Routing = (): JSX.Element => {
return (
<>
{publicRouting.map(({ path, component }, i) => (
<Route key={i} path={path} element={component} />
))}
{isAuthenticated() && (
<Main>
{routing.map(({ path, component }, i) => (
<Route key={i} path={path} element={component} />
))}
</Main>
)}
</>
);
};
Right now console throw me this error:
index.tsx:19 Uncaught Error: [Routing] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>
can someone tell me how to solve this problem? It looks like this component has incompatible type and cannot go as children between Routes
component, but why they changed it? How to correct my Routing
component?
Thanks for any help!
Via Active questions tagged javascript - Stack Overflow https://ift.tt/7ZWEbgv
Comments
Post a Comment