You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
476 B
TypeScript

import { FC, PropsWithChildren } from 'react'
import { useLocation, Navigate } from 'react-router-dom';
import { useAppSelector } from '../../hooks/redux';
const OnlyUnauthorized: FC<PropsWithChildren> = ({children}) => {
const {isAuth} = useAppSelector(state => state.UserSlice);
const location = useLocation();
if (isAuth) {
return <Navigate to="/" state={{ from: location }} replace />;
}
return children;
}
export default OnlyUnauthorized;