import { useState } from 'react'; import { Redirect, Link } from "react-router-dom"; import { Formik } from 'formik'; import { useAuth } from "../../utils/context"; import * as Yup from 'yup'; import catchErrors from "../../utils/catchErrors"; import styles from "./form.module.scss"; const LoginForm = () => { const { login } = useAuth(); const [success, setSuccess] = useState(false); const [error, setError] = useState(""); if (success) { return ; } return ( <> { try { setError("") const result = await login(values) if (result) { setSuccess(true) } } catch (error) { catchErrors(error, setError) resetForm(); } setTimeout(() => { setSubmitting(false); }, 400); }} > {formik => ( {formik.touched.userId && formik.errors.userId ? ( {formik.errors.userId} ) : null} {formik.touched.password && formik.errors.password ? ( {formik.errors.password} ) : null} 로그인 회원가입 )} > ); } export default LoginForm;