Move renderCallbacks to VNode and queue refs as renderCallbacks#3860
Closed
andrewiggins wants to merge 10 commits into
Closed
Move renderCallbacks to VNode and queue refs as renderCallbacks#3860andrewiggins wants to merge 10 commits into
andrewiggins wants to merge 10 commits into
Conversation
📊 Tachometer Benchmark ResultsSummaryduration
usedJSHeapSize
Results02_replace1k
duration
usedJSHeapSize
run-warmup-0
run-warmup-1
run-warmup-2
run-warmup-3
run-warmup-4
run-final
03_update10th1k_x16
duration
usedJSHeapSize
07_create10k
duration
usedJSHeapSize
filter_list
duration
usedJSHeapSize
hydrate1k
duration
usedJSHeapSize
many_updates
duration
usedJSHeapSize
text_update
duration
usedJSHeapSize
todo
duration
usedJSHeapSize
|
|
Size Change: +2.16 kB (3%) Total Size: 56.5 kB
ℹ️ View Unchanged
|
Bring back _renderCallbacks on component to fix Suspense test. I believe this fixes the test because it allows queued render callbacks (namely componentDidMount) to persist across suspensions. So cDM is queued on initial render when the component suspends. When the component resumes, cDM is still in the queue and is flushed and called on resumption.
f103446 to
f8b36c3
Compare
e8718e9 to
08fbf3b
Compare
7937956 to
ebde2e4
Compare
Member
Author
|
Note: Memory will increase slightly because of this PR because I'm adding a new field to every VNode: In v11 we can reclaim this back because we won't have _renderCallbacks on both Component and Internals. There will only be one on Internals. |
Member
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.
Ref callbacks can be used for side-effects involving DOM nodes such as setting up IntersectionObservers or measuring width/height of DOM elements for manual positioning. However in Preact today, refs are applied while we are rendering in
diffChildren. For updates, this is acceptable because the DOM nodes are already attached to the document. When mounting, we apply refs after appending a DOM child to its parent. However, if that DOM node's parent hasn't been mounted yet, then the ref callback is invoked before the DOM node is attached to the document. This PR changes our ref application logic to always apply refs as render/commit callbacks to ensure they are applied after DOM elements have been fully attached to the document.Resurrect #2098 to fix issue with ref and effect ordering.