import React from 'react' ; import { Route , Redirect , RouteProps } from 'react-router-dom' ; import { checkLogin } from '@/utils' ; type Props = { component : React . ComponentClass | React . FunctionComponent ; } & RouteProps ; export const AuthRoute = ( { component : Component , ... rest } ) => ( < Route { ... rest } render = { props => checkLogin ( ) ? ( < Component { ... props } / > ) : ( < Redirect to = { { pathname : '/login' , state : { from : props . location } } } />)}/ > ) ;