onCreate 이후 property 의 undefind 에러
해결됨
한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
add 후에 List페이지로 이동하면, 흰화면으로 에러가 출력됩니다. Home.js 의 프로퍼티에 대해 undefind 가 출력됩니다. [Uncaught TypeError: Cannot read properties of undefined (reading 'length') at Home.js:15:1] [ diaryList.length >= 1 ] : 에러 발생하는 부분 useEffect (() => { if ( diaryList . length >= 1 ) { //에러발생부분 const firstDay = new Date ( curDate . getFullYear (), curDate . getMonth (), 1 ). getTime (); const lastDay = new Date ( curDate . getFullYear (), curDate . getMonth () + 1 , 0 ). getTime (); setData ( diaryList . filter (( it ) => firstDay <= it . date && it . date <= lastDay ) ); } }, [ diaryList , curDate ]);
- Home.js
- javascript
- property
- nodejs
- undefind
- react
- length
gwi01304
댓글 2
좋아요 0
조회수 419





