Closed sunwoo0706 closed 2 years ago
기존 useMarker hook 내부의 로직은 data (companyListData) 가 바뀔때마다 setState의 prevState 를 이용하여 marker를 생성하기 때문에 데이터 중복 문제가 있었다. 그 때문에 swr의 자동 갱신 기능과 더불어 웹페이지에 포커스 될 때마다 필요없는 마커들이 렌더링되었다.
useMarker
prevState
data.forEach
The latest updates on your projects. Learn more about Vercel for Git ↗︎
개요
기존
useMarker
hook 내부의 로직은 data (companyListData) 가 바뀔때마다 setState의prevState
를 이용하여 marker를 생성하기 때문에 데이터 중복 문제가 있었다. 그 때문에 swr의 자동 갱신 기능과 더불어 웹페이지에 포커스 될 때마다 필요없는 마커들이 렌더링되었다.작업 내용
data.forEach
로직에 들어가기전 setState를 초기화