I’m trying to migrate from react-router v5 to react-router v6. I can’t figure out a clear way of converting this code to v6 syntax.
What will be the v6 equivalent of this snippet?
import React, { Suspense } from "react";
import { Route, Switch, Redirect } from "react-router-dom";
import AuthLayout from "Layouts/auth.layout";
import Loading from "pages/loading";
const LoginPage = React.lazy(() => import("./login"));
const SignupPage = React.lazy(() => import("./signup"));
const User = (props) => {
return (
<AuthLayout>
<Suspense fallback={<Loading />}>
<Switch>
<Redirect
exact
from={`${props.match.url}/`}
to={`${props.match.url}/login`}
/>
<Route
path={`${props.match.url}/login`}
render={() => <LoginPage />}
/>
{/* <Route
path={`${props.match.url}/signup`}
render={() => <SignupPage />}
/> */}
<Redirect to="/error" />
</Switch>
</Suspense>
</AuthLayout>
);
};
export default User;