Props.children

Suxxzzy.log·2022년 2월 8일
0

에러핸들링

목록 보기
14/32

프롭스 다양하게 내려주고 쓰는 방법
children 으로 작성한 부분을 주목해 둘 것.



부모
...
  return (
    <div>
      <div>작성자: {currentUser}</div>
      <NewTweetForm addfunc = {addNewTweet}/>
      <ul id = "tweets">
        {tweets.map((t) => {
          <SingleTweet key = {t.uuid} writer = {t.writer} date = {t.date}>
            {t.content}
          </SingleTweet>
        })}
      </ul>
    </div>
  )
}

자식
function SingleTweet({writer,date,children}){
  return(
    <li>
      <div>{writer}</div>
      <div>{date}</div>
      <div>{children}</div>
    </li>
  )
}
profile
몫을 다하는 사람

0개의 댓글