-
Notifications
You must be signed in to change notification settings - Fork 3
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
Bug/location 동일 동명 선택 가능 #34
Conversation
- 도시명/시/구 + 동 이름으로 표시
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전체적으로 좋습니다. 오늘은 의견이 많은 것 같기도 하네요 😅
헌데 yarn.lock이 또 올라와있고 .gitignore는 삭제되었네요.
이 부분은 같이하거나 제가 조금있다가 추가적인 커밋을 하도록 하겠습니다.
고생하셨습니다 주나미 😊
const dongName = (region: string) => region.split(" ").reverse()[0]; | ||
const cityName = (region: string) => region.split(" ").reverse()[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
의견입니다!
현재 dongName
, cityName
은 함수인데, 꼭 일반 변수처럼 보이네요..
앞에 get이라던지 동사가 붙어있다면 어떨까요?
또한 함수를 2개를 선언하는 것이 아닌
const getRegionInfo = (region: string) => region.split(" ").reverse();
dongName, cityName을 불러올 때는
const [dongName, cityName] = getRegionInfo(location)
{searchLogs.map((location, idx) => | ||
!isSameDong ? ( | ||
<TargetButton | ||
key={idx} | ||
displayName={dongName(location)} | ||
onDeleteItemClick={handleDeleteTarget(location)} | ||
/> | ||
) : ( | ||
<TargetButton | ||
key={idx} | ||
displayName={cityName(location) + " " + dongName(location)} | ||
onDeleteItemClick={handleDeleteTarget(location)} | ||
/> | ||
), | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
의견입니다!
searchLogs.map((location, idx) =>
이 부분 뒤에서 지금처럼 바로 조건에 따른 JSX를 리턴하는게 아닌
const [dongName, cityName] = getRegionInfo(location)
이렇게 미리 값을 계산해놓고 JSX를 렌더하는 건 어떨까요?
{searchLogs.map((location, idx) => {
const [dongName, cityName] = getRegionInfo(location);
return !isSameDong ? (
<TargetButton key={idx} displayName={dongName} onDeleteItemClick={handleDeleteTarget(location)} />
) : (
<TargetButton
key={idx}
displayName={`${cityName} ${dongName}`}
onDeleteItemClick={handleDeleteTarget(location)}
/>
);
})}
또한 일반적인 경우에는 "~동" 으로만 나오고 같은 동이 있을 경우에는 "~구 ~동"으로만 나오는 로직이군요.
멋집니다 :)
기능요약 (이 PR은 어떤 일을 하나요?)
작업내용
이 PR이 필요한 이유 (optional)
변경사항에 대한 렌더링 화면 변화를 캡처해 첨부해주세요.