-
Bernard Roland (Student Com20) authoredBernard Roland (Student Com20) authored
LoginRoute.tsx 504 B
import { Route, RouteProps, useHistory } from 'react-router-dom';
import { isLoggedIn } from 'adapters/api';
import { useEffect } from 'react';
export default function LoginRoute(props: RouteProps) {
const history = useHistory();
useEffect(() => {
if (isLoggedIn()) {
if (history.length === 0) {
history.push('/tasks');
} else {
history.goBack();
}
}
})
return (
<Route {...props} />
);
}