codestates / codestates/BanThing

[Error Handling] 데이테의 마커가 표시가 되지 않는 오류

Open
#154 0 comments 0 reactions 1 assignee Claimed by @tmdqls2257 View on GitHub
client error solved
Dominant language
TypeScript
Stars
0
Forks
2
PR merge metrics
No merged PRs in 30d

Description

### 어떤 에러인가요?
![image](https://user-images.githubusercontent.com/54207332/155260871-e2fe922b-9093-426a-8fad-d256bd2ac6c6.png)

- 데이테의 마커가 표시가 되지 않는 오류
![image](https://user-images.githubusercontent.com/54207332/155260936-2bbaea9f-eafe-408e-b238-5dd56eae0b28.png)

- 분명 데이터 베이스에 데이터가 잘 들어가 있다.
![image](https://user-images.githubusercontent.com/54207332/155261027-37fdcb3f-6775-4978-a872-e175560715cb.png)

- console.log(1)을 찍게 되면 지도 마커가 표시가 된다.
```
$ 터미널의 에러 코드를 여기 넣어주세요.
```

### 에러 핸들링 방법
![image](https://user-images.githubusercontent.com/54207332/155262303-cde3af04-bbd1-4e66-a1f9-57fc120a870f.png)

- 먼저 useEffect에 대해서 알아보자
- 기본적으로 useEffect는 처음 렌더링이 될 때마다 useEffect가 사용되지만 조건부를 source props만 변경해준다면 source props만이 변경될 때만 useEffect가 사용된다.
-
```
useEffect(
() => {
const subscription = props.source.subscribe();
return () => {
subscription.unsubscribe();
};
},
[data?.data.postList.length],
);
```
이렇게하면 data?.data.postList.length가 변할 때만 렌더링이 된다.

Why?
그렇다면 배열의 변화가 없을 때는 렌더링 되지 않아야 하는데 왜 렌더링 되는 걸까?
이 부분은 notion에 작성하여 좀 더 알아보자

### 에러 핸들링을 위해 참고한 레퍼런스 링크
- Memory-It 의 Error Handling 예시입니다.
[리액트 공식홈페이지](https://ko.reactjs.org/docs/hooks-reference.html#useeffect)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.