import { useState } from 'react'; import { Redirect, Link } from "react-router-dom"; import { Formik } from 'formik'; import { useAuth } from "../../utils/context.js"; import * as Yup from 'yup'; import catchErrors from "../../utils/catchErrors.js"; 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 { console.log('login values', values) 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;