Routing
Routing
StrikingDash use react-router as base routing system. To add a new route in the template, you can follow the steps below.
Create new route
We place all our pre and post login page components in src/routs/ folder. auth.js file is for authentication and admin folder contains all admin paenl routes.
index.js in this folder is the entry point of all pages, you can basically set your pages in this file.
Refer below mentioned code to create a route:
import React, { lazy, Suspense } from 'react';
import { Switch, Route, useRouteMatch } from 'react-router-dom';
const Dashboard = lazy(() => import('./dashboard'));
const Ecommerce = lazy(() => import('./ecommerce'));
const Admin = () => {
const { path } = useRouteMatch();
return (
<Switch>
<Suspense
fallback={
<div className="spin">
<Spin />
</div>
}
>
<Route path={path} component={Dashboard} />
<Route path={`${path}/ecommerce`} component={Ecommerce} />
</Suspense>
</Switch>
);
};
export default withAdminLayout(Admin);