Login.js
510 Bytes
import { Navigate, useNavigate } from "react-router-dom";
const Login = () => {
console.log("visit Login");
const session = localStorage.getItem("session");
const navigate = useNavigate();
const login = () => {
if (true) {
//login success
localStorage.setItem("session", true);
navigate("/");
}
};
return session ? (
<Navigate to="/" />
) : (
<div className="Login">
<button onClick={login}>로그인</button>
</div>
);
};
export default Login;