import { Link } from "react-router-dom"; import React, { useEffect, useState } from "react"; import userApi from "../../apis/user.api"; const INIT_PROFILE = { id: "", avatarUrl: "", }; const InfoUpdate = () => { const [profile, setProfile] = useState(INIT_PROFILE); // useEffect(()=>{ // setProfile() // },[profile]) const handleChange = async (event) => { const { name, files } = event.target; let formData = new FormData; formData.append("avatarUrl", files[0]); const res = await userApi.profileimg(formData); console.log(res.img) console.log(res.id) setProfile({ ...profile, avatarUrl: res.img}) setProfile({ ...profile, id:res.id}) }; const{id,avatarUrl}=profile; return (
#{profile.id}
); }; export default InfoUpdate;