import { useState } from 'react'; import { Redirect, Link } from "react-router-dom"; import { Formik } from 'formik'; import * as Yup from 'yup'; import authApi from '../../apis/auth.api'; import catchErrors from "../../utils/catchErrors.js"; const LoginForm = () => { const [success, setSuccess] = useState(false); const [error, setError] = useState(""); if (success) { return ; } return ( <> { try { setError("") const result = await authApi.login(values) if (result.status === 201) { setSuccess(true) } } catch (error) { catchErrors(error, setError) } 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;