3 ms·
Hi! I'm the author and was very surprised to see my post here. I mainly wrote it as a reference for my future self. Someone pointed out that I've muddied up th
by SnowmanJoshu 12y ago
Hi! I'm the author and was very surprised to see my post here. I mainly wrote it as a reference for my future self.
Someone pointed out that I've muddied up the distinction between the DOM and react's virtual DOM. That is entirely possible! I should point out that I am a React novice and in no way an authoritative source.
I'm assuming when a render function gets run, it does an actual DOM render, but I could be wrong.
- dignati 12y agoThe render function only renders to the virtual DOM, which React diffs with the previous rendered virtual DOM to decide what changes to the real DOM have to be made. That's why the render function is, or should be, efficient.
- DougBTX 12y agoHi! That might be my comment down below. There's a nice article about how the diffing works here: http://calendar.perfplanet.com/2013/diff/ http://calendar.perfplanet.com/2013/diff/ The important bit is that the diff is applied to the old and new virtual doms, and it is the render method that gets called to compute the new virtual dom. Only after the diff does the real dom get updated.
- SnowmanJoshu 12y agoOhhh. Alright, that makes much more sense. I was assuming the diffing algorithm took place pre-render. Thanks =)