12 - ReactJS Virtual DOM - What are Virtual DOM, Reconciliation, Diffing, and Batch Update in React?

  Рет қаралды 35,846

tapaScript by Tapas Adhikary

tapaScript by Tapas Adhikary

Күн бұрын

"What is Virtual DOM in React?" - Have you heard someone asking this question to you? 😉
So, let's provide the answer to that question. We will also learn the concepts of Reconciliation, Diffing algorithms, and Batch Updates to the original DOM. All set? Let's get started. 🐥
Timecodes
0:00 - Introduction
00:38 - Understanding DOM
05:30 - ReactJS Virtual DOM
08:46 - How does Virtual DOM work?
12:53 - What is Reconciliation Process in React?
14:02 - What is Diffing Algorithm?
17:48 - Wrapping Up
Important Links
-----------------------------
- Twitter: / tapasadhikary
- Blog: blog.greenroots.info/
- Showwcase React Community: www.showwcase.com/community/r...
Liked my work? Do you want to support my work?
* www.buymeacoffee.com/greenroots
Thank You 🙏

Пікірлер: 166
@tapasadhikary
@tapasadhikary 2 жыл бұрын
Content of the Video 0:00 - Introduction 00:38 - Understanding DOM 05:30 - ReactJS Virtual DOM 08:46 - How does Virtual DOM work? 12:53 - What is Reconciliation Process in React? 14:02 - What is Diffing Algorithm? 17:48 - Wrapping Up
@farazali5335
@farazali5335 Жыл бұрын
Virtual DOM and Reconciliation: React creates a copy of original dom to avoid making direct changes in the original. When a change occurs in any state, a new copy of virtual dom is created reflecting that change, Now react will do diffing on the new and earlier virtual dom to specify the changes, And now it will batchup changes of several virtual doms finally reflect it in the original DOM. This process is called Reconciliation. Diffing Algorithm 1- If the root or parent element has changed, its child elements are considered to be changes as well and will be included in the reconciliation. 2- When checking li elements, the diff algorithm checks all elements to match for any changes or removed or new element. This takes a toll on performance and thats why keys are used when printing list items as such, to make the differentiation easier and faster.
@tapasadhikary
@tapasadhikary Жыл бұрын
Great 👏
@mrmadhan8557
@mrmadhan8557 Жыл бұрын
great summary thank you brother
@tapasadhikary
@tapasadhikary Жыл бұрын
Most welcome 🔥
@miraclenerdkidchiki6249
@miraclenerdkidchiki6249 10 ай бұрын
Nice summary bruv 💯
@arankengineer7947
@arankengineer7947 8 ай бұрын
sir , above in line 5 , => "And now it will batchup changes of several virtual doms finally reflect it in the original DOM " ,does it mean for any event if state get change it create different virtual dom for parent and every child component ? and what if multiple states of the same component get changed for any event will it create that many virtual dom@@tapasadhikary
@martinkarugaba
@martinkarugaba Жыл бұрын
I have been writing React js code for three years but I had never wrapped my head around the concept of the virtual DOM. Your explanation today was exceptionally clear. Thank you very much Tapas. Please continue doing this. I think you're really good at it.
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks, Martin. I am very glad to add to your knowledge. Keep learning, Man!
@lindatochukwu3081
@lindatochukwu3081 5 ай бұрын
I'm on the 12th video, I never understood some concepts, but going through your videos, boosted my confidence in some concepts in React JS, thank you so much for breaking it down into understandable pieces
@tapasadhikary
@tapasadhikary 5 ай бұрын
That’s great to hear, keep going 🚀
@mumbaikapunter007
@mumbaikapunter007 2 жыл бұрын
Thanks mate, short and crisp, to the point. Keep up the good work
@tapasadhikary
@tapasadhikary 2 жыл бұрын
Thanks a lot, 💙
@deepakkumarkhatri
@deepakkumarkhatri 8 ай бұрын
Thank you, sir, for contributing to this video. You have explained everything smoothly and I've cleared all my doubts. Keep doing great work for the community.
@tapasadhikary
@tapasadhikary 8 ай бұрын
Super 👌
@shashankbhatgs1150
@shashankbhatgs1150 10 ай бұрын
Wow, just the right video i was looking for. Came here to understand just reconciliation, but understood so many concepts like virtual dom, diffing and especially why we use the key attribute. Thanks for making this amazing video!
@tapasadhikary
@tapasadhikary 10 ай бұрын
Yay, so glad to hear that. Feel free to check other videos too from the React series 👏🚀💛
@shashankbhatgs1150
@shashankbhatgs1150 10 ай бұрын
sure, definitely!
@faizanabbas-i
@faizanabbas-i 2 ай бұрын
Really Helpful Video to understand these concepts. Thanks for providing such content.
@tapasadhikary
@tapasadhikary 2 ай бұрын
You are most welcome ❤️
@rohanthakur9159
@rohanthakur9159 Жыл бұрын
Thanks a lot Tapas for explaining in such a simple manner. I got to learn a lot from your video. Keep up the good work.👏
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks a lot, Rohan
@pratikdevle5830
@pratikdevle5830 2 жыл бұрын
short and clear explanation, beginner friendly really liked it.
@tapasadhikary
@tapasadhikary 2 жыл бұрын
Ah, very glad.
@mrmadhan8557
@mrmadhan8557 Жыл бұрын
by far the best explanation i can get on reconciliation. Thanks a lot subbed
@tapasadhikary
@tapasadhikary Жыл бұрын
Welcome Madhan ✌️
@Sanyat100
@Sanyat100 8 ай бұрын
easily the best explanation in the internet about DOM
@tapasadhikary
@tapasadhikary 8 ай бұрын
Wow, thanks!
@ricklove8358
@ricklove8358 11 ай бұрын
man this is what i exactly needed. God bless you. Showing love from Tanzania
@tapasadhikary
@tapasadhikary 11 ай бұрын
Wow great 💛
@jinoshkurisinkal3169
@jinoshkurisinkal3169 Жыл бұрын
Crystal clear explanation of Virtual DOM.
@tapasadhikary
@tapasadhikary Жыл бұрын
Thank you, Jinosh 💙
@ajayarya3914
@ajayarya3914 Жыл бұрын
Very clean and clear explanation. Awesome 👍
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks a lot, Ajay 💙
@Victor-wh9bs
@Victor-wh9bs 11 ай бұрын
Great explanation.ThankU
@tapasadhikary
@tapasadhikary 11 ай бұрын
Thanks a lot.
@supershinobi7892
@supershinobi7892 Жыл бұрын
i never had any lecture like this love it
@tapasadhikary
@tapasadhikary Жыл бұрын
Thank you!
@amindavids710
@amindavids710 Жыл бұрын
great explanation , clear one
@tapasadhikary
@tapasadhikary Жыл бұрын
Thank you 🙏
@khemendrabhardwaj8805
@khemendrabhardwaj8805 Жыл бұрын
Loved the concept . Thanks for amazing explanation
@tapasadhikary
@tapasadhikary Жыл бұрын
I'm glad you liked it 👍
@talhaahmad7179
@talhaahmad7179 Жыл бұрын
Best video i found on the topic in two days 👍
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks a lot ❤️
@cyberdaria
@cyberdaria 11 ай бұрын
Nice and clear vid, thanks!
@tapasadhikary
@tapasadhikary 11 ай бұрын
Most welcome 👏
@sugrivlodhi2607
@sugrivlodhi2607 Жыл бұрын
I realy love your way of teaching
@tapasadhikary
@tapasadhikary Жыл бұрын
Thank you so much 🙏
@irshadkk9704
@irshadkk9704 8 ай бұрын
very usefull video.thanks for the wonderfull content
@tapasadhikary
@tapasadhikary 8 ай бұрын
Most welcome 🤗
@miraclenerdkidchiki6249
@miraclenerdkidchiki6249 10 ай бұрын
I love this teaching method....its so in-depth and clearly explained...thanks so much brother👍
@tapasadhikary
@tapasadhikary 10 ай бұрын
Thanks a lot.
@skillfulmind960
@skillfulmind960 8 ай бұрын
Very useful content and the explanation style is awesome .....
@tapasadhikary
@tapasadhikary 8 ай бұрын
Thank you! Glad it helped you.
@shubham5646
@shubham5646 4 ай бұрын
what a teaching style and content u have amazing
@tapasadhikary
@tapasadhikary 4 ай бұрын
Thanks Shubham ❤️
@andrewaghoghovwia1948
@andrewaghoghovwia1948 Жыл бұрын
Thanks alot mate.. fully understood
@tapasadhikary
@tapasadhikary Жыл бұрын
Super, glad you liked 💙
@manikaraheja2491
@manikaraheja2491 Жыл бұрын
Deep concepts explained in very interesting way. Thanks
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks a lot, Manika ✌️
@rishiranjan2822
@rishiranjan2822 Жыл бұрын
Sir this is absolutely gold explanation....cleared many doubts...tysm!
@tapasadhikary
@tapasadhikary Жыл бұрын
Great, glad to know 👍
@lifeofmrc
@lifeofmrc Жыл бұрын
Amazing video thank you
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks a lot, you are welcome.
@diamondrock4945
@diamondrock4945 Жыл бұрын
Best of the best videos on DOM
@tapasadhikary
@tapasadhikary Жыл бұрын
I'm so glad 💙
@harshitrajani8369
@harshitrajani8369 Жыл бұрын
Great video please keep posting
@tapasadhikary
@tapasadhikary Жыл бұрын
Sure thing! Wil do.
@visheshgupta4990
@visheshgupta4990 4 ай бұрын
Thank you so much it is very well explained good video
@tapasadhikary
@tapasadhikary 4 ай бұрын
Thank You
@deepaksingh9928
@deepaksingh9928 Жыл бұрын
Superb explained
@tapasadhikary
@tapasadhikary Жыл бұрын
Thank you
@techexpertpremiere
@techexpertpremiere Жыл бұрын
Thank you for this great explanation of React Virtual DOM. I did not know much about react virtual dom. It seems like to see your video I clear all doubt about the react virtual DOM. Again Thank you.
@tapasadhikary
@tapasadhikary Жыл бұрын
I am glad that you found it helpful, Omar.
@techexpertpremiere
@techexpertpremiere Жыл бұрын
@@tapasadhikary Your tutorial was the main factor of clear about react virtual dom or VDOM. I think every react developer should know about the concept of VDOM. I think this concept will be help me lot in future when I will worked with react project.
@tapasadhikary
@tapasadhikary Жыл бұрын
Very glad to know 🤩
@sublimeelectrons8699
@sublimeelectrons8699 9 ай бұрын
thank you sir @tapas! Very well explained. Now I understood why react is undoubtedly fast. I understooD DOM, Virtual DOM ,Diffing(Its like Differential signals in signal mixing) algorithm in just 18minutes. Nobody does it better than you sir. Great job again and again.
@tapasadhikary
@tapasadhikary 9 ай бұрын
That's great, keep going 🚀
@asthadeepak
@asthadeepak Жыл бұрын
Very useful tanmay Thanks for the video
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks Astha 🙏 It’s Tapas, btw 😅
@muxtech9046
@muxtech9046 2 ай бұрын
Love from Pakistan, very helpful , far better than other channel not to mention they record just to sell courses , but your lectures are quite deep full of knowledge , Sir you great!
@tapasadhikary
@tapasadhikary 2 ай бұрын
Thank you, it means a lot ❤️
@billypentester
@billypentester 10 ай бұрын
best ever explanation of virtual DOM
@tapasadhikary
@tapasadhikary 10 ай бұрын
Wow, made my day 💛
@sumitpal8689
@sumitpal8689 Жыл бұрын
Very good explanation, any dummies can understand the way you have explained. Awesome, keep doing this good job
@tapasadhikary
@tapasadhikary Жыл бұрын
Great hearing that, Sumit 🤩
@themelodymusic1658
@themelodymusic1658 9 ай бұрын
Amazing video!
@tapasadhikary
@tapasadhikary 9 ай бұрын
Thanks a lot 💛
@grabydeal
@grabydeal Жыл бұрын
wow., amazing explanation
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks a lot 👍
@praptipandey7771
@praptipandey7771 9 ай бұрын
Really good explanation
@tapasadhikary
@tapasadhikary 9 ай бұрын
Glad you liked it.
@KoushikChatterjeephp
@KoushikChatterjeephp Жыл бұрын
Owesome explanation. Better than any paid tutorial.
@tapasadhikary
@tapasadhikary Жыл бұрын
Means a lot 💙
@tahreenbanu2812
@tahreenbanu2812 10 ай бұрын
Very nice explanation....
@tapasadhikary
@tapasadhikary 10 ай бұрын
Thanks a lot, I’m glad 💛
@TheCodingCollege8462
@TheCodingCollege8462 11 күн бұрын
Thank you boss
@jaycodes8790
@jaycodes8790 2 жыл бұрын
Amazing video man!
@tapasadhikary
@tapasadhikary 2 жыл бұрын
Thank you
@education24carat
@education24carat Жыл бұрын
Great lecture
@tapasadhikary
@tapasadhikary Жыл бұрын
Thank you!
@siddiqajamadar2283
@siddiqajamadar2283 2 жыл бұрын
Thank you so much for valuable information
@tapasadhikary
@tapasadhikary 2 жыл бұрын
You are most welcome 💙
@vishalkuwar6579
@vishalkuwar6579 6 ай бұрын
Useful video 👍
@tapasadhikary
@tapasadhikary 6 ай бұрын
Thanks for watching ❤️
@fithamlakfikrie4657
@fithamlakfikrie4657 Жыл бұрын
Great explanation !
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks a lot 👍
@sulaimanshabbir
@sulaimanshabbir Жыл бұрын
Thank you ❤
@tapasadhikary
@tapasadhikary Жыл бұрын
Most welcome ✌️
@jatilyadav4000
@jatilyadav4000 Жыл бұрын
Amazing video
@tapasadhikary
@tapasadhikary Жыл бұрын
Thank you, Jatil 🙏
@Hrit
@Hrit 8 ай бұрын
Thank you so much
@tapasadhikary
@tapasadhikary 8 ай бұрын
Most welcome
@surajchaudhary1162
@surajchaudhary1162 Жыл бұрын
Became ur fan 🥰 The way u explain 🔥🔥
@tapasadhikary
@tapasadhikary Жыл бұрын
Wow, thanks a lot 💙
@prashlovessamosa
@prashlovessamosa Жыл бұрын
Thank you sir
@tapasadhikary
@tapasadhikary Жыл бұрын
Welcome
@willianandrade1357
@willianandrade1357 2 жыл бұрын
Very good video Tapas! But to be honest, these concepts are hard to swallow... specially the diffing algorithms. I'll rewatch your video and read the docs to fully grasp the idea. Thank you for your work.
@tapasadhikary
@tapasadhikary 2 жыл бұрын
Thanks, William. Please feel free to ask ur doubts in the comments section, I'll try responding as well 😊
@willianandrade1357
@willianandrade1357 2 жыл бұрын
@@tapasadhikary The first question I have is about the diffing algorithms you talked about. You taught me how they work but didn't name them. So, if I understood correctly there's: a diffing algorithm specially for changes on root elements and their content, another one specially for changes in attributes (this one I didn't quite understand) and another one for listing content and list elements. And all of them only work in JSX, since all of this is because of the DOM and Virtual DOM shenanigans. Is this right?
@tapasadhikary
@tapasadhikary 2 жыл бұрын
Yes all respect to JSX as that is what constructs Virtual DOM and renders. The second one is if the root doesn't change, it compares for the attribute change. That's where diffing happens again!
@qR7pK9sJ2t
@qR7pK9sJ2t 4 ай бұрын
MAGICAL !!!!
@sakinamosavi1104
@sakinamosavi1104 Жыл бұрын
very helpful thanks
@tapasadhikary
@tapasadhikary Жыл бұрын
You are most welcome 💙
@sapnasawai5199
@sapnasawai5199 Жыл бұрын
It's really very useful
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks a lot
@anushasurakala5975
@anushasurakala5975 2 ай бұрын
Thank you
@tapasadhikary
@tapasadhikary 2 ай бұрын
Most welcome.
@KeshavAggarwaltechy
@KeshavAggarwaltechy 2 жыл бұрын
Hi Tapas, Found your tutorial after searching for react js, I myself is Python Django developer, I too teach stuff related to python. I wanted to enhance myself on more modular stuff in frontend part. Your videos are great help Great stuff Also Camera and background enhancement is awesome, :) Thank you
@tapasadhikary
@tapasadhikary 2 жыл бұрын
Thanks, Keshav 💙. Sharing knowledge is a divine thing. Great to know you contribute to the Python community 👍.
@GoWithLyrics
@GoWithLyrics Жыл бұрын
Codeevaluation is bets for React & redux
@sunilgeorge8864
@sunilgeorge8864 8 ай бұрын
Good explanation brother. Keep rocking. Also put a video on React Fibre and Stack
@tapasadhikary
@tapasadhikary 8 ай бұрын
Thanks brother 🙏
@akshaypatil8393
@akshaypatil8393 Жыл бұрын
Yes sir it is vary useful knowledge you provide. sir please make video about Routing.
@tapasadhikary
@tapasadhikary Жыл бұрын
Sure
@shortme9374
@shortme9374 Жыл бұрын
Liked, Subscribed. Thank you sir for making such clear and informative video.
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks a lot. It’s motivating
@shortme9374
@shortme9374 Жыл бұрын
@@tapasadhikary if possible then remove that rolling subscribe button which comes below the video. it diverts the attention.
@tapasadhikary
@tapasadhikary Жыл бұрын
Will take care from new videos
@nourrahim5556
@nourrahim5556 Жыл бұрын
YOU are greateeeeeeeeee
@tapasadhikary
@tapasadhikary Жыл бұрын
Thank you 🙏
@user-gi9bn3hf4k
@user-gi9bn3hf4k 7 ай бұрын
This video is providing much clarity abut the DOM working, but since you displaying like ,subscribe, and the bell icon at the bottom of page is distracting to user. I suggest you to that it can be showed only once at the time of video starting. NOTE: Good videos automatically gets subscribed.
@tapasadhikary
@tapasadhikary 7 ай бұрын
In fact, I have removed it altogether in my recent videos... Thanks for going through and as you liked it, I believe you have subscribed too 😄
@naruto5437
@naruto5437 Жыл бұрын
excellent
@tapasadhikary
@tapasadhikary Жыл бұрын
Thanks a lot 👍
@adarshjaiswal7334
@adarshjaiswal7334 Жыл бұрын
What do you mean by saying in-memory object and how is it different from the real DOM obj?
@devT44
@devT44 Жыл бұрын
Sir, what is heuristic algorithm? Where does it fits in the entire process? Is it same as diff algorithm?
@arankengineer7947
@arankengineer7947 8 ай бұрын
sir, why do not we use ordered list instead of ul , it can tell specific order of change and no need for key
@bishwajeetpandey1570
@bishwajeetpandey1570 Жыл бұрын
I have a doubt at 10:15 You said if parent component states changes then react will mark all it's child components changes . Now suppose if parent component have a use state and that use state is only used by a one child component and there are others child elements but they don't use this useState they are simply static components. And latter on when the parent use state changes due to some event will it's all child component who is not using the useState will also be marked as changes to new virtual dom and will be re-rendered on the screen. If yes then where is the performance optimization in this scenario ?
@tapasadhikary
@tapasadhikary Жыл бұрын
> Now suppose if parent component have a use state and that use state is only used by a one child component and there are others child elements but they don't use this useState they are simply static components. Here are a few terminologies we need to understand. Child never gets Parent's state. A component's state is private to itself. One way the state value gets passed to child is using the props(which is not same as the state). So if A passed the props to B and B doesn't pass to C, the prop change from A to B will impact only B except the case the B itself changes in such a way the it has be teared down and built again. On top of this we can bring optimization for cases where the props is a heavily computed value or something that doesn't change often. Those cases we can think using the memo. However, it shouldn't be used often without considering if we really need it.
@bishwajeetpandey1570
@bishwajeetpandey1570 Жыл бұрын
@@tapasadhikary thank u so much
@random2059
@random2059 11 ай бұрын
Please reply 🙏🙏🙏 So react show us illumination of actual Dom just to save computational power and under the hood it slowly update the actual Dom time to time by algorithms set ???? so getElement by Id , getElement by class goes away 😂
@tapasadhikary
@tapasadhikary 11 ай бұрын
It's conceptually the same but handled in memory instead of tweaking the actual DOM. Think it like, you have data store and you have replicated some portion of it in memory and perform actions on it than doing it on the DB directly. DOM methods like getElementbyxxx stays but as React is declarative(please watch the secret sauce video of React series) so it abstracts way interacting with those low level APIs directly. Thanks for watching 💛
@GoWithLyrics
@GoWithLyrics Жыл бұрын
when you asked for special attention in video, you also started poping subscribe and like popup's...great clap for you
@tapasadhikary
@tapasadhikary Жыл бұрын
That must be a pleasing coincidence 😀. I hope you liked the content, though.
@GoWithLyrics
@GoWithLyrics Жыл бұрын
@@tapasadhikary yes content is very good…i understood about VD
@rashedmia7849
@rashedmia7849 3 ай бұрын
I am waiting for Javascript advance course with dsa.❤❤❤
@tapasadhikary
@tapasadhikary 3 ай бұрын
That's a good ask... I will start on it after my ongoing course.
@chromepos
@chromepos 2 жыл бұрын
please, do redux tutorial
@tapasadhikary
@tapasadhikary 2 жыл бұрын
Yeah, will do
@tapasadhikary
@tapasadhikary Жыл бұрын
It;s available now. Please check and let me know.
@ashishprasad2949
@ashishprasad2949 Жыл бұрын
DOM Api is provided by browser, not JS
@tapasadhikary
@tapasadhikary Жыл бұрын
Yes these APIs are not core part of the language, however available as wrapper JS Web APIs developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model
@nawarajluitel9171
@nawarajluitel9171 Жыл бұрын
Thank you sir
@tapasadhikary
@tapasadhikary Жыл бұрын
Welcome 💙
Can you beat this impossible game?
00:13
LOL
Рет қаралды 64 МЛН
How Does React Actually Work? React.js Deep Dive #1
15:25
Philip Fabianek
Рет қаралды 133 М.
Virtual DOM, Fibre and reconciliation
13:44
Hitesh Choudhary
Рет қаралды 18 М.
Beginner React.js Coding Interview (ft. Clément Mihailescu)
36:31
Ben Awad
Рет қаралды 2,1 МЛН
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 383 М.
How React ACTUALLY works (DEEP DIVE 2023)
12:59
FrontStart
Рет қаралды 48 М.
Understanding React's UI Rendering Process
29:07
CrossComm, Inc.
Рет қаралды 205 М.
React Fiber Reconciliation: How it Works (Part 1)
13:43
Tejas Kumar
Рет қаралды 9 М.
Can you beat this impossible game?
00:13
LOL
Рет қаралды 64 МЛН