import React , { FC , useEffect } from 'react' ; import { useAuth } from './AuthContext' ; import AuthenticatorLoadingScreen from './AuthenticatorLoadingScreen' ; interface Props { autoLogin : boolean ; checkLogin : ( ) => void ; } export const CheckAuth = ( { autoLogin , checkLogin , children } ) => { const { userInfo } = useAuth ( ) ; useEffect ( ( ) => { if ( ! userInfo ) { checkLogin ( ) ; } } , [ ] ) ; const renderChildren = ! autoLogin || userInfo ; return renderChildren ? < > { children } < /> : <AuthenticatorLoadingScreen / > ; } ;