mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 18:29:15 +03:00
30 lines
768 B
TypeScript
30 lines
768 B
TypeScript
import React from 'react';
|
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
import { Route } from 'react-router-dom';
|
|
import { RouteProps } from 'react-router';
|
|
import { IPageProps } from '@educt/interfaces';
|
|
import ErrorFallback from '@educt/components/ErrorFallback';
|
|
|
|
export interface IPublicRouteProps extends RouteProps {
|
|
component: React.FC<IPageProps>;
|
|
title: string;
|
|
}
|
|
|
|
/**
|
|
* Render public page
|
|
*/
|
|
const PublicRoute: React.FC<IPublicRouteProps> = ({ component: Component, title, ...options }) => {
|
|
return (
|
|
<Route
|
|
{...options}
|
|
render={props => (
|
|
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
|
<Component {...props} title={title} />
|
|
</ErrorBoundary>
|
|
)}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default PublicRoute;
|