본문 바로가기

REACT/해결방안

Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead

참조 : https://stackoverflow.com/questions/47658765/objects-are-not-valid-as-a-react-child-found-object-promise/47659112

 

Objects are not valid as a React child (found: [object Promise])

I am trying to render a list of posts by mapping through an array. I've done this many times before but for some renderPosts = async () => { try { let res = await axios.get('/posts')...

stackoverflow.com

React에서 axios , cheerio 를 사용하여 크롤링을 연습하던 도중 생긴 문제.

 

Console 에는 원하는만큼 전부 찍히지만 Render() 안으로 값이 들어가기만 하면 바보가 되네요

 

this.renderPosts() will return a Promise not the actual data, and AFAIK Reactjs will not resolve Promises implicitly in render.

->

this.renderPosts()는 실제 데이터가 아닌 Promise를 반환하고, AFAIK Reactjs는 렌더에서 암묵적으로 Promises를 해결하지 않는다.

 

Promise 에 대해서 잘 알지 못해 생긴 문제였습니다.