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

home2 게시판 Next.js 게시판 게시판 정보를 props 로 넘겨줄 때 오류가 납니다.

게시판 정보를 props 로 넘겨줄 때 오류가 납니다.

2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 글쓴이
  • #84089
    export default async function List(){
        const db = (await connectDB).db("forum");
        let result = await db.collection('post').find().toArray()
        return(
            <ul className="list-bg">
                <ListItem result={result}/>
            
        )
    }
    
    
    export default function DetailLink({result}){
        return (
            <div>
                {
                    result.map(el =>{
                            return <li key={el._id} className="list-item">
                                <Link prefetch={false} href={`/detail/${el._id}`}>
                                    <h4>{el.title}</h4>
                                </Link>
                                <Link href={'/edit/' + el._id}>수정</Link>
                                <span onClick={()=>{
                                    fetch('/api/post/delete', {method : 'DELETE' , body: el._id})
                                }}  >삭제</span>
                                <p>{el.content}</p>
                            
                            }
                        )
                }
            </div>
        )
    }
    
    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: "안녕요", 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: {}, content: "두번째글다시시", title: ...}
            ^^
    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: "세번째글", 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: "1234", 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: "1234", 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: "글 제목 확인", content: ...}
            ^^
    
    왜 선생님 강의 영상에서는 그냥 toString안해주고 result 써도 오류없이 되는데 저는 안될까요..?
    #84115

    codingapple
    키 마스터
    오류는 아니고 워닝인데 _id는 뒤에 .toString() 전부 붙여서 보내야하는데 아마 뒤에 나옵니다
2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 답변은 로그인 후 가능합니다.

About

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

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

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