import React, { useState } from 'react'; import { Formik } from 'formik'; import * as Yup from 'yup'; import axios from 'axios'; import 'bootstrap/dist/css/bootstrap.css'; import { Link, Redirect } from 'react-router-dom'; function Change() { // const [state, setState] = useState(false); // if (state) { // return ; // } return (
{ axios.put(`/users`, { ...values, id: localStorage.getItem('id') }, ) .then(res => { console.log(res.data); if (res.status === 404) return alert(res.data.error) alert("회원정보가 수정되었습니다!") }) .catch(err => { alert(err.error) }); setTimeout(() => { setSubmitting(false); }, 400); // finish the cycle in handler }} > {({ errors, touched, handleSubmit, getFieldProps, // contain values, handleChange, handleBlur isSubmitting, }) => (
{touched.password && errors.password ? (
{errors.password} ) : null}
{touched.password2 && errors.password2 ? (
{errors.password2}
) : null}
)}
); } export default Change;