• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 Next.js 게시판 _id 값이 안넘어옵니다

_id 값이 안넘어옵니다

  • 이 주제에는 5개 답변, 2명 참여가 있으며 codingapple2 년 전에 전에 마지막으로 업데이트했습니다.
6 글 보임 - 1 에서 6 까지 (총 6 중에서)
  • 글쓴이
  • #87215

    윤종은
    참가자
    server component -> client component 넘어올 때 _id 값이 안넘어옵니다
    
    /list/page.js
    code
    /list/ListItem.js 하던 페이지
    code2
    /list/ListItem.js 쌤 코드로 했을 때
    code1
    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에서 제가 잘 못 된게 있을까요?ㅠ
    
    
    
    
    		
    	
    #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/
    
    #87660

    윤종은
    참가자
     code3
    code31
    워닝은 링크 보고 해결 했는데
    
    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 하면 빈칸만 출력 됩니다
    스크린샷 2023-06-20 015722
    
    #87672

    codingapple
    키 마스터
    result는 array자료같은데 ._id 뒤에 붙이면 안될듯요
    #88776

    윤종은
    참가자
    근데 강의에서 /list/page.js 에서 넘겨주는 <ListItem result={result} />
    똑같이 넘겨주는데 
    저는 왜 array로 넘어오는거죠?
    #88810

    codingapple
    키 마스터
    강의에서도 array자료형일걸요
6 글 보임 - 1 에서 6 까지 (총 6 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠