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] window이벤트 제거, 새로고침시 채널 선택 버그 수정 #161

Merged
merged 1 commit into from
Jul 22, 2022

Conversation

wogha95
Copy link
Member

@wogha95 wogha95 commented Jul 17, 2022

📌 기능 설명

  • window 이벤트 제거
    • 뒤로가기 이벤트를 감지하여 화면을 고치는 작업을 리팩토링하였습니다.
  • 새로고침 시 채널 선택 버그 수정
    • 기존 코드의 제거로 인해 새로고침시 채널이 선택되는 작업이 제거되었는데 재구현하였습니다.

👩‍💻 요구 사항과 구현 내용

  • window 이벤트 제거
    • pushstate 부분은 react-router의 navigate를 이용하였습니다.
    • popstate 부분은 react-router의 useParams로 변동될 때마다 채널ID를 받아서 채널의 목표 목록을 보여주도록 구현하였습니다.
  • 새로고침 시 채널 선택 버그 수정 (아래 코드 추가)
const clickedChannel = channelsData?.filter(
  (item) => item._id === channelId
)[0];
setSelectedChannel(clickedChannel);

🔍피드백

  • 채널 페이지의 38번째 줄에서 typescript오류가 나오는데 해결하지 못하였습니다.
  • 하지만 화면 렌더링에는 오류없이 나와서 일단 PR올립니다. 혹시나 관련하여 아시는 분 계시면 코멘트 부탁드립니다.

스크린샷 2022-07-18 05 20 01

@wogha95 wogha95 requested a review from chogyejin as a code owner July 17, 2022 20:21
@wogha95 wogha95 self-assigned this Jul 17, 2022
@vercel
Copy link

vercel bot commented Jul 17, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
shallenge ✅ Ready (Inspect) Visit Preview Jul 17, 2022 at 8:21PM (UTC)

@wogha95 wogha95 linked an issue Jul 17, 2022 that may be closed by this pull request
(item) => item.description === channelDescription
)[0];
setSelectedChannelId(_id);
history.pushState(null, null, `/challenges/${_id}`);
navigate(`/challenges/${_id}`);
Copy link
Member

Choose a reason for hiding this comment

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

Array.prototype.filter의 반환값이 배열인데 바로 구조분해할당으로 id를 꺼내서 그런 걸까요??

Copy link
Member Author

Choose a reason for hiding this comment

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

현재 VScode 껐다 켰는데 빨간 밑줄이 사라집니다..
merge하고 동일한 현상이 발생시 코멘트 참고하여 수정해보겠습니다!
(재시동된 현재 channelsData의 타입을 인식하기에 _id가 string으로 뜹니다!)

@wogha95 wogha95 merged commit 59bed4b into main Jul 22, 2022
@sa02045 sa02045 deleted the refactor/challenges-page branch July 24, 2022 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[3주차] window 이벤트 제거
2 participants