I want to display main pages and side pages. In my case, I want to separate pages with one template and pages with another template. At the moment I have a MainPages component with a header and sidebar and AccountVerificationPages without a header and sidebar.
const MainPages = () => {
// path is "/"
const { path } = useRouteMatch();
return (
<div className={classes.appRoot}>
<Sidebar />
<div className={classes.appContent}>
<Header />
<Switch>
<Route path={path} exact>
<Suspense fallback={<PageLoading />}>
<IndentedTemplate>
<MainPage />
</IndentedTemplate>
</Suspense>
</Route>
<Route path={`${path}browse`} exact>
<Suspense fallback={<PageLoading />}>
<IndentedTemplate>
<MainPage />
</IndentedTemplate>
</Suspense>
</Route>
<Route path="*">
<div>404</div>
</Route>
</Switch>
</div>
</div>
);
};
const AccountVerificationPages = () => {
const { path } = useRouteMatch();
return (
<Switch>
<Route path={`${path}/reset-password/:token`} exact>
<Suspense fallback={<PageLoading />}>
<FullHeightTemplate>
<ResetPasswordPage />
</FullHeightTemplate>
</Suspense>
</Route>
<Route path={`${path}/verify/:token`} exact>
<Suspense fallback={<PageLoading />}>
<FullHeightTemplate>
<VerifyEmailPage />
</FullHeightTemplate>
</Suspense>
</Route>
<Route path="*">
<div>404</div>
</Route>
</Switch>
);
};
<Switch>
{/* Main pages ("/", "/home", "/profile", etc.). keeps the main template with sidebar and header */}
<Route path="/" component={MainPages} />
{/* Side pages keeps other template without sidebar and header */}
<Route path="/account" component={AccountVerificationPages} />
<Route path="*">
<div>404</div>
</Route>
</Switch>
But in this case, I get the routing for the Main Pages component. How to separate routes for MainPages and for AccountVerificationPages?