티스토리 뷰

 

Error: Objects are not valid as a React child (found: object with keys {text}). If you meant to render a collection of children, use an array instead.

 

React Component 렌더링할때 Component로 전달된 데이터와 표시하는 데이터의 타입이 일치하지 않아서 에러 발생

 

타입을 잘못 썼나 싶어서 다 뒤지고 다녔는데 전달하는 데이터도 string이고 표시하는 데이터도 string 인거..

대체 뭐가 문제지 하고 있었는데 props 값을 적지 않아서 생긴 오류였다..

바보!

 


// 에러뜬 코드
const Title = () => {

     ...

};


// 수정한 코드
const Title = ({text}) => {
     ...

};

최근에 올라온 글
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31