-
Notifications
You must be signed in to change notification settings - Fork 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
Partial tree re-renders #45
Comments
Yeah, I have thought about this a little bit as well. As you said, we might be able to detect when to stop going down the tree. The key thing here is to know from which point in the tree the data has changed (from root or some component). Actually, in order to know which items to re-render, we need a way of figuring out which state/props are used in the We could start with a slightly better 'watch' mechanism in combination with checking if a subtree has not changed. |
This is exactly what However, that will also render subcomponents, etc.... thinking about this makes my head spin :) |
💡 Rendering the whole tree will inevitably happen (although sometimes just from a component down when only local state has changed), but the trick is that we can skip a lot of comparisons (or rather reconciliation) of the rendered VNodes by skipping subtrees that are not marked as changed. |
Currently, the Instead, we should be able to schedule updates in a queue for specific subtrees (as mentioned in your first post). Then during the update of the subtree, if there is watcher on the VNode, we should be able to 'skip' that subtree. The subtree should just be triggered by changes to its own props. I think that the fiber structure that is currently in place makes things harder to reason about (with the whole concept of WIP tree and such), so we might benefit from combining fiber + VNode like Vue does? Another 'trick' from Vue 3 is to 'hoist' static elements, so static parts don't do any reconciliation.
So also a list of Edit: interesting read: https://wuchwuw.github.io/vue-next-analysis/runtime-core/vnode.html (in Chinese? Here is a link to google translate: https://wuchwuw-github-io.translate.goog/vue-next-analysis/runtime-core/vnode.html?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp) |
Some more interesting reading material for figuring out some of Svelte's tricks: https://lihautan.com/compile-svelte-in-your-head/ |
Some more tricks from dioxus: https://dioxuslabs.com/blog/templates-diffing/ |
(I'm mostly wondering how complicated this would be to implement)
When you get an event because of a state change, it should be possible to only re-render the tree from the source of the event down.
Also, I wonder, in the event that you are re-rendering a (sub)tree, can you stop going down the tree when at some point it turns out the props and state for a component have not changed? I think that would guarantee that subtree is not in need of any further attention, right?
Of course it might be that further down below there was another state change... Hmm...
Just thinking 💬 🧠
The text was updated successfully, but these errors were encountered: