[3팀 김대현] Chapter 2-2. 나만의 React 만들기 - #43
Open
daehyunk1m wants to merge 9 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
과제 체크포인트
배포 링크
https://daehyunk1m.github.io/front_7th_chapter2-2/
기본과제
가상돔을 기반으로 렌더링하기
이벤트 위임
심화 과제
Diff 알고리즘 구현
과제 셀프회고
개인적인 사정으로 이번 과제를 진행하는 주간에 시간을 많이 투입할 수 없었지만
다행히 easy 난이도가 생겨서 과제를 마무리할 수 있었습니다.
이번 과제를 수행하며 AI의 가이드를 따라 최대한 구현하고 리액트가 해결하려고 한 문제를 깊히 경험해보려고 노력했습니다.
아하! 모먼트 (A-ha! Moment)
초기에
updateElement에서 불필요한 자식 노드를 제거할 때 앞에서부터 제거하는 방식으로 구현했습니다.그런데 "oldChildren이 newChildren보다 많을 때" 케이스가 계속 실패했습니다.
디버깅 결과, 앞에서부터 자식을 제거하면 DOM의 index가 틀어지는 문제를 발견했고 역순으로 제거하여 해결했습니다.
기술적 성장
React의
ReactDOM.render()가 어떻게 효율적으로 DOM을 업데이트하는지 직접 구현하며 이해했습니다.또한 과제를 진행하며 적절한 자료구조를 선택하여 로직을 구현할 수 있게 되었습니다.
updateElement를 구현하며 diff 알고리즘을 명확한 단계로 구조화할 수 있게 되었습니다.코드 품질
리팩토링이 필요한 부분
1. 이벤트 타입 하드코딩 (eventManager.js:14)
2. Style 속성의 카멜케이스 미변환
개선 방안
학습 효과 분석
좋은 추상화는 복잡도를 감추면서도 필요할 때 제어할 수 있게 합니다.
React가 얼마나 많은 복잡도를 숨기고 있는지 체감했습니다.
쉽게 jsx를 사용하면서 느끼지 못했지만 그 내부에는 이 모든 것이 자동으로 일어납니다.
과제 피드백
테스트 케이스가 명확하게 요구사항을 정의하고 있어 과제를 수행해나가면서 로직이 작동하는 프로세스를 쉽게 따라갈 수 있었습니다.
각 단계를 통과할 때마다 성취감을 느낄 수 있었고, 막히는 부분도 명확히 파악할 수 있었습니다.
처음에 렌더링이 되지 않아 흰 화면에서 함수를 작성해 리액트의 기능을 만들어 정상적으로 Virtual DOM으로 렌더링하는 것이 인상적이었습니다.
React 없이 JSX를 직접 처리하고, Virtual DOM을 구현하는 경험이 매우 좋았습니다.
리뷰 받고 싶은 내용