AuthenticatedRoutes
Routing component made with react-router-dom
Props
- authenticated - (required) Boolean value to check if user is authenticated or not
- privateRoutes - (not required)
RouteTypes[]
Array of private routes - publicRoutes - (not required)
RouteTypes[]
Array of public routes - generalRoutes - (not required)
RouteTypes[]
Array of general routes - loading - (not required) set it to true, if you want to show loading animation
- loadingComponent - (not required) if not set then default animation will show, set it to show your own loading component
RouteTypes
same as react-router-dom RouteProps
- path - (required) path of the route
- element - (required) component to render
- children - (not required) children routes
Usage
import { AuthenticatedRoutes } from 'react-componentry';
const App = () => {
return (
<AuthenticatedRoutes
authenticated={true}
privateRoutes={[
{
path: '/dashboard',
component: Dashboard,
},
]}
publicRoutes={[
{
path: '/login',
component: Login,
},
]}
generalRoutes={[
{
path: '/',
component: Home,
},
]}
/>
);
};