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