{
modal == true ? <Modal 글제목={글제목}/> : null
}
이렇게 해서 글제목state를 자식컴포넌트로 보내고
function Modal(props){
return (
<div className="modal">
<h4>{ props.글제목 }</h4>
<p>날짜</p>
<p>상세내용</p>
</div>
)
}
여기까지 하면 부모에게서 받아온 컴포넌트가 잘 출력됩니다. 근데
<h4>{ props.글제목 }</h4> 이걸 <h4>{ props.글제목[0] }</h4> 이라고 하면
Cannot read properties of undefined (reading '0') 이란 오류가 납니다.
props가 잘 된거 같은데 왜 [0]를 사용하면 이런 오류가 나는걸까요?