import { useSelector } from "react-redux";
import { Navigate, useLocation } from "react-router-dom"

const NoRequireAuth = ({children}) => {
    const location = useLocation();
    const auth = useSelector(state => state.auth.user)

    if (auth){
        return <Navigate to='/profile' state={{from: location}} />
    }
    return children
}

export default NoRequireAuth