-
Notifications
You must be signed in to change notification settings - Fork 65
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
[13팀 김유진] [Chapter 1-2] 프레임워크 없이 SPA 만들기 #28
base: main
Are you sure you want to change the base?
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.
2주차도 고생많으셨습니다💪
element._cleanup = cleanup; | ||
} | ||
} | ||
}, 0); |
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.
setTimeout(() => {
const element = document.querySelector(`[id="${props.id}"]`);
if (element) {
// 이전에 등록된 클린업 함수가 있다면 실행
if (element._cleanup) {
element._cleanup();
}
// 새로운 ref 콜백 실행 및 반환된 클린업 함수 저장
const cleanup = props.ref(element.parentElement);
if (typeof cleanup === "function") {
element._cleanup = cleanup;
}
}
}, 0);
저는 처음에 setTimeout이 0초로 설정되어있어서 이러면 타임아웃을 거는 이유가 뭘까 생각해보고 찾아봤는데, 0으로 설정해도 바로 실행되는게 아니라는 것을 배우고 갑니다 ㅎ
dom이 다 그려진 이후에 클린업을 체크하려고 넣으신걸로 이해했는데 제가 맞게 이해한게 맞을까요??
}; | ||
|
||
const actions = { | ||
addPost: (state, newPost) => { |
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.
postStore를 분리해서 사용하니 관심사별로 store 관리가 명확해지고, 코드 유지보수성이 확실히 좋아질 것 같아요!덕분에 한수 배우고 갑니다!👍🏻
|
||
export const PostForm = () => { | ||
const handleSubmit = () => { | ||
console.log("포스트 작성 이벤트 등록"); |
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.
콘솔로그가 귀엽게 남아있어용ㅎㅎ
} | ||
|
||
if (vNode.children) { | ||
$el.append(...vNode.children.map(createElement)); |
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.
저는 appendChild만 알고 있었어서 append는 모지..?! 하고 찾아보니 용도는 비슷하지만
- appendChild
- DOMNode만 추가 가능
- 하나의 요소만 추가 가능
- append
- DOMNode뿐만 아니라 text도 추가 가능
- 여러개의 요소를 한 번에 추가 가능
요런 차이점이 있더라구요! append가 더 최신 문법이고 유용한 것 같아용 하나 배워갑니다~~✨
과제 체크포인트
기본과제
가상돔을 기반으로 렌더링하기
이벤트 위임
심화 과제
1) Diff 알고리즘 구현
2) 포스트 추가/좋아요 기능 구현
과제 셀프회고
이번 과제를 통해 Virtual DOM의 동작 원리와 이벤트 위임의 실제 구현에 대해 깊이 있게 이해할 수 있었습니다. 특히 Diff 알고리즘을 직접 구현하면서 React의 내부 동작 방식을 더 명확하게 파악할 수 있었고, 이는 앞으로의 React 개발에 큰 도움이 될 것 같습니다. 또한 이벤트 버블링과 캡처링의 개념을 실제 코드로 구현하면서, 브라우저의 이벤트 처리 메커니즘에 대한 이해도도 한층 높아졌습니다.
기술적 성장
코드 품질
학습 효과 분석
리뷰 받고 싶은 내용
스토어를 응용해서 만들고 싶어서 postStore.js를 만들어서 상태를 업데이트 하다보니 globalStore와 postStore 간의 의존성이 높이보이는 것 같기도 해서 이 부분에 대한 코치님의 피드백 부탁드립니다.