-
Notifications
You must be signed in to change notification settings - Fork 0
[DongHyun] Virtual DOM #1
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
base: donghyun
Are you sure you want to change the base?
Conversation
| setCount(count + 1); | ||
| }; | ||
|
|
||
| // return ( |
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.
이 주석은 일부러 남겨둔 것인가요??
| * NOTE: createElement Helper Function | ||
| */ | ||
| export function isHTMLElement(element: DocumentFragment | HTMLElement) { | ||
| return element instanceof HTMLElement; |
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.
타입 단언과 instanceof 2가지 경우를 썼는데 차이가 뭔가요??
저는 Fragment가 아티클에 없어서 굳이 구현하지 않았는데 굳이 구현해보면 좋겠군요!! |
|
|
고민한 것.
Virtual DOM을 만들고, RealDOM으로 변환하는 과정에서 Fragment를 어떻게 구현할 수 있을까에 대한 고민함. 이 부분은 React Core 소스코드를 보았는데,
Symbol을 사용해서 고유한 문자열을 만드는것을 보고, 다음과 같이 간략하게 만들었음.위처럼 작성하니 React의 Fragment처럼 잘 동작하지만 "이게 최선인가"에 대해 고민을 더 해봐야함.
해당 아티클에서는 Fragment 구현하는 부분이 없어서 아쉬웠음 😂
배운 점.
전반적으로 Virtual DOM을 직접 구현하면서 기존 이론을 이해하는데 도움이 되었음. 나중에 내가 멘토링을 한다면 이 과정을 꼭 해보라고 하고싶음. 이론적으로 아는것과 코드로 직접 구현하는건 너무나 큰 차이가 있다는 것을 알게되었음.
구현을 하기전에 요구사항 정의를 해야하는데, 이게 쉽지가 않음. 항상 답안지를 보는데 고민과 고통을 더 겪어야 할 것 같음.
Note
기존에 Fragment를 사용하면 에러가 발생했는데, 지금은 Fragment 잘 동작함!