import React from "react" ; import { Route , Redirect , RouteProps } from "react-router-dom" ; interface IPrivateRouteProps extends RouteProps { isLoggedIn : boolean ; } function PrivateRoute ( { isLoggedIn , children , ... rest } ) { return ( < Route { ... rest } render = { ( { location } ) => isLoggedIn ? ( children ) : ( < Redirect to = { { pathname : "/signin" , state : { from : location } , } } />)}/ > ) ; } export default PrivateRoute ;