codestates / HomeTownAlba

0 stars 0 forks source link

[21.11.10] 에러핸들링 (김지윤) - 객체 state 내에 key:value 추가 #89

Open jacobways opened 2 years ago

jacobways commented 2 years ago

문제 상황 및 에러 로그

const openApplicantList = (jobId, idx) => {
  axios.get(`http://localhost:5000/applicant/${jobId}`, {withCredentials: true})
  .then((res)=> {
    setApplicantList(applicantList[idx] = [res.data.data])
  })
}

원인 및 해결방안

setApplicantList({ ...applicantList, [idx]: res.data.data });