Skip to content

Instantly share code, notes, and snippets.

@kimshun0213kr
Last active January 3, 2024 13:48
Show Gist options
  • Save kimshun0213kr/4a35b8533825b5ce98faf482b954dc06 to your computer and use it in GitHub Desktop.
Save kimshun0213kr/4a35b8533825b5ce98faf482b954dc06 to your computer and use it in GitHub Desktop.
/src/pages/login/indez.tsx
import { Button, HStack, VStack } from "@chakra-ui/react";
import { useState } from "react";
import { UseLoginState } from "@/hooks/LoginState";
export default function Main() {
const [InputId, setInputId] = useState("");
const [InputPass, setInputPass] = useState("");
const [isLogin, setIsLogin, setLogout] = UseLoginState(false);
function login() {
setIsLogin(InputId, InputPass);
}
return (
<>
<HStack>
<VStack>
<p>IDを入力</p>
<input
placeholder="IDを入力"
onChange={(e) => setInputId(e.target.value)}
/>
</VStack>
<VStack>
<p>パスワードを入力</p>
<input
placeholder="パスワードを入力"
onChange={(e) => setInputPass(e.target.value)}
type="password"
/>
</VStack>
<Button onClick={login}>ログイン</Button>
</HStack>
{isLogin ? (
<>
<h1>ログイン済み</h1> <Button onClick={setLogout}>ログアウト</Button>
</>
) : null}
</>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment