I ma student and I m trying to create own Virtual DOM for my college project ( It will not have any advanced feature like props or events, I will keep it simple ) in JavaScript like other famous frameworks React, Vue and other.
I just want to know that when we have multiple file of code( code splitting ). If I make a change in any deep child than do I need to compare complete virtual DOM (including all child and parent element) or I just need to compare only that child elements.
If I have to compare complete new virtual DOM ( including all children ) with previous Virtual DOM. Then Why should I care re-rendering in React or Vue ( because any changes in child will force the framework to compare complete Virtual DOM )
Answer to your last point as I infer from my experience of React is that comparing Virtual DOM's in Javascript is the thing that helps react know what things it has to re-render on the actual DOM, So the "re-rendering" is the hard part on which the performance of the APP takes the hit. Hopefully, this would help.
For Vue, The working of virtual DOM differs in vue2 and vue3.
The way vue3 does it, is,
dynamicData = { data1: [ effect1, effect2, ... ], data2: [ effect4, effect5, ... ], ... }
References:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.