JSX를 반환할 때, 서버에서 데이터를 가져오기 전이면 다음의 에러가 나타난다.
Cannot read properties of undefined (reading 'email')
수정 전
return (
<div>
{profile.email}
<div/>
)
가져온 데이터가 있을 때만, 접근하게끔 코드를 수정하면 된다.
수정 후
return (
<div>
{profile && profile.email}
<div/>
)