Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 콜스택
- resource server
- 판교브루클린
- 이벤트루프
- access token
- 개발도서추천
- 브라우저동작
- nextjs
- react
- BOJ
- 매크로태스크큐
- NextImage
- 브루트포스
- 리팩터링2판
- 자바스크립트엔진
- getInitialProps
- 마이크로태스크큐
- NextImageSpan
- backend
- prevProps
- NeXT
- Next이미지
- resource owner
- flexible box
- componentDidUpdate
- 브라우저동작원리
- CSS
- 자바스크립트런타임
- getServerSideProps
- nestjs
Archives
- Today
- Total
imgyuzzzang
[NEXT JS] getServerSideProps는 Date 객체를 허락하지 않아,, 본문
computer science/에러로그
[NEXT JS] getServerSideProps는 Date 객체를 허락하지 않아,,
imgyuzzzang 2022. 11. 22. 20:45츨처: https://github.com/vercel/next.js/issues/13209#issuecomment-633149650
세 줄 요약
- object ("[object Date]") cannot be serialized as JSON. Please only return JSON serializable data types. 오류 발생
- NextJS 에서는 getInitialProps, getServerSideProps, getStaticProps 의 리턴 값으로 plain Object만을 허용
- 특정 (Date, Map, Set) 타입을 퍼포먼스 이슈로 인해 지원하지 않음
해결 방법
JSON.parse(JSON.stringify(객체))사용
safe-json-stringify 라이브러리 사용 (1번이랑 다를게 뭐지…?)
import safeJsonStringify from 'safe-json-stringify'; ... export async function getServerSideProps() { ... return { props: { JSON.parse(safeJsonStringify(객체)) } }; }
next-superjson-plugin설치 + 넥스트 컨피그 설정
// next.config.js module.exports = { experimental: { swcPlugins: [ [ 'next-superjson-plugin', { excluded: [], }, ], ], }, }
'computer science > 에러로그' 카테고리의 다른 글
[Warning] Each child in a list should have a unique "key" prop : map function 사용 시 key값 필요 (0) | 2021.03.02 |
---|
Comments