티스토리 뷰
React/error
React : 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.
w0ny 2020. 12. 18. 10:15
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}) => {
...
};