codestates / codestates/Subllet
[ERR] TypeError: map
Open
ERR
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
### 어떤 에러인가요?
- axios 통신요청후 받아온 데이터(배열형태)를 map 함수를 이용하니 에러메세지가 나옴
### 에러 메시지
```shell
TypeError: Cannot read properties of undefined (reading 'map')
```
### 에러 핸들링 방법
- 첫 렌더링될 때 map을 이용하면 아직 데이터가 없을 때 먼저 렌더링이 되기 때문에 undefined를 map하게되어 오류가 났다
- &&을 이용했다 (앞의 조건이 참이면 && 뒤에 조건을 실행하고 앞의 조건이 거짓이면 React는 뒤에 조건을 무시한다)
### 에러 핸들링을 위해 참고한 레퍼런스 링크
https://devbirdfeet.tistory.com/47
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.