6 글 보임 - 1 에서 6 까지 (총 6 중에서)
-
글쓴이글
-
2023년 6월 16일 14:14 #87215
윤종은참가자server component -> client component 넘어올 때 _id 값이 안넘어옵니다 /list/page.js
/list/ListItem.js 하던 페이지
/list/ListItem.js 쌤 코드로 했을 때
Warning: Only plain objects can be passed to Client Components from Server Components. Objects with toJSON methods are not supported. Convert it manually to a simple value before passing it to props. {_id: {}, title: "안녕1", content: "반가워1"} ^^ Warning: Only plain objects can be passed to Client Components from Server Components. Objects with toJSON methods are not supported. Convert it manually to a simple value before passing it to props. {_id: {}, title: "두번째글1", content: ...} ^^ Warning: Only plain objects can be passed to Client Components from Server Components. Objects with toJSON methods are not supported. Convert it manually to a simple value before passing it to props. {_id: {}, title: "333번째글1", content: ...} ^^ 두개다 이런식으로 뜨는 상황입니다 toJSON 메서드가 있는 개체가 지원 안된다는데 server component에서 JSON 형식으로 바꿔서 해야되는건가요? 아니면 client component에서 제가 잘 못 된게 있을까요?ㅠ
2023년 6월 16일 18:47 #87266
codingapple키 마스터워닝이라 무시해도 될걸요 아니면 이거 참고합시다 https://codingapple.com/forums/topic/listitem%ec%9c%bc%eb%a1%9c-props%eb%a5%bc-%eb%84%98%ea%b2%a8%ec%a4%84-%eb%95%8c-%eb%82%98%eb%8a%94-warning/
2023년 6월 20일 02:00 #87660
윤종은참가자워닝은 링크 보고 해결 했는데 list/page.js → ListItem 페이지로 result값 넘겨주는데 - result값은 넘어오는데(toString 넣고 _id값이 "고유id"이 아닌, '고유id'으로 출력) - _id 값이 넘어오지 않습니다(undefined) ==출력================================
>>> ListItem page : [ { _id: '645bb2575888a7fef7d31f7d', title: '안녕1', content: '반가워1' }, { _id: '645cee323d5c717e29a895ac', title: '두번째글1', content: '두번째 글내용1' }, { _id: '645d166d3d5c717e29a895ad', title: '333번째글1',
>>> result._id : undefined ==================================== 그래서 브라우저에서 span(쓰레기통) onClick 하면 빈칸만 출력 됩니다
-
글쓴이글
6 글 보임 - 1 에서 6 까지 (총 6 중에서)
- 답변은 로그인 후 가능합니다.