Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 마커 렌더링을 최적화 한다 #737

Merged
merged 10 commits into from
Sep 15, 2023
Merged

Conversation

kyw0716
Copy link
Member

@kyw0716 kyw0716 commented Sep 15, 2023

📄 Summary

Marker 컴포넌트에서 마커를 렌더링하고, 이벤트 핸들러를 달아주던 기존 방식에서 StationMarkersContainer 컴포넌트에서 마커의 생성과 관련된 모든 로직을 일괄 처리 하는 방식으로 수정했습니다.

추가적으로 모바일에서 StationDetailsWindow가 마커 클릭시에 바로 열리지 않도록 수정했고, 모바일 환경에서 마커 클릭시 지도의 이동이 부자연스러웠던 것도 개선했습니다.

로직 변경으로 인해 기존에는 하위 컴포넌트(마커)의 개수만큼 마커 인스턴스 전역 상태 변경이 발생했던 문제를 개선했습니다. 그 효과로 드르륵 찍히던 마커들이 한번에 찍히게 되었습니다.

개선 전

before

개선 후

after

🕰️ Actual Time of Completion

5시간

🙋🏻 More

로직을 개선하면서 기존의 기능 중 동작하지 않는 기능이 생겼습니다. 이전 방식을 그대로 사용해서 기능을 살리려 했으나 이전 방식이 상태 변경에 의한 사이드 이펙트에 의존하는 방식이다보니 이를 개선할 필요성이 있다고 판단해 다음 이슈에서 해결하도록 하겠습니다.

동작하지 않는 기능

  • 검색어 입력으로 화면 이동시 선택된 충전소에 간단 정보창이 열리는 기능

close #732

@kyw0716 kyw0716 added 🛠️ 리팩터링 개선사항입니다 FE 프론트엔드 관련 이슈입니다 labels Sep 15, 2023
@kyw0716 kyw0716 self-assigned this Sep 15, 2023
@kyw0716 kyw0716 temporarily deployed to test September 15, 2023 03:08 — with GitHub Actions Inactive
@kyw0716 kyw0716 temporarily deployed to test September 15, 2023 03:10 — with GitHub Actions Inactive
@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/

1 similar comment
@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/


import type { StationMarker } from '@type';

import CarFfeineMarker from '../../../ui/CarFfeineMarker/index';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

절대 경로 사용해주세요~

stationMarkers
);

const remainMarkerInstances = getRemainMarkerInstances(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

왜 동사원형이죠? 😮

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 영어 실력 이슈입니다

Comment on lines +29 to +31
const newMarkers = markers.filter((marker) =>
prevMarkerInstances.every((prevMarker) => prevMarker.stationId !== marker.stationId)
);
Copy link
Collaborator

@feb-dain feb-dain Sep 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[질문] newMarkers가 이전 범위 바깥에 있었던 새로운 마커들을 의미하나요?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로캣맨

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새로 fetch한 마커들 에서 이전의 마커 영역에 겹치는 부분을 제외한 나머지 영역에 해당하는 마커들을 의미합니다

});
};

const getRemainMarkerInstances = (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getRemainedMarkerInstances 아닐까요??

Comment on lines +30 to +31
const latitude = screen.get('isMobile') ? lat + latitudeDelta / 3 : lat;
const longitude = screen.get('isMobile') ? lng : lng - calculatedMapDelta / 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3이랑 2은 뭔가요??😯 상수화 해주세요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

말 그대로 수치의 절반이랑 3분의 1이란 의미인데 이건 어떻게 상수화 할 수 있을까요?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어떤 의미인지, 왜 사용했는지 코드상으로 알 수 없을 때 주석이나 상수를 활용하면 좋겠어요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

무조건 상수화를 생각하면 오히려 가독성을 해칠 수 있으니 앞으로 상수화 하기 어려운 요소에 대해서는 주석으로 설명을 추가해두겠습니다!

@kyw0716 kyw0716 temporarily deployed to test September 15, 2023 05:56 — with GitHub Actions Inactive
@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/

Copy link
Member

@gabrielyoon7 gabrielyoon7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿샷

@kyw0716 kyw0716 temporarily deployed to test September 15, 2023 06:33 — with GitHub Actions Inactive
@kyw0716 kyw0716 merged commit c520483 into develop Sep 15, 2023
2 checks passed
@kyw0716 kyw0716 deleted the refactor/732 branch September 15, 2023 06:34
@github-actions
Copy link

🚀storybook: https://storybook.carffe.in/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FE 프론트엔드 관련 이슈입니다 🛠️ 리팩터링 개선사항입니다
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

마커 렌더링을 최적화 한다
3 participants