import { useCheckAuth } from 'ra-core' ; import { useEffect } from 'react' ; import { useHistory } from 'react-router' ; example export const useRedirectIfAuthenticated = ( redirectTo = '/' ) => { const history = useHistory ( ) ; const checkAuth = useCheckAuth ( ) ; useEffect ( ( ) => { checkAuth ( { } , false ) . then ( ( ) => { history . push ( redirectTo ) ; } ) . catch ( ( ) => { } ) ; } , [ checkAuth , history , redirectTo ] ) ; } ; export type UseRedirectIfAuthenticatedOptions = string ;