Virtual Dom kaise kaam krta hai ?

 


                Virtual Dom kaise kaam krta hai ? 


Virtual DOM ka funda samajhne ke liye pehle real DOM ke baare mein thoda sa bata doon. Real DOM woh actual HTML elements hote hain jo browser mein dikhte hain, jaise ki heading tag, paragraph tag, ya koi bhi HTML tags.

Virtual DOM basically real DOM ki copy hai . Jab hum koi change karte hain apne webpage mein, jaise ki koi text update ya element remove karna ho, toh sabse pehle woh change Virtual DOM mein hota hai, Real DOM mein nahi. Yeh Virtual DOM kaafi fast hota hai as compared to Real DOM, because it's just a copy, not the actual thing that the user sees.

Ab, jab yeh changes Virtual DOM mein hote hain,then React smartly compares the current Virtual DOM with the previous one, using a process called "reconciliation." Woh dekhta hai kya changes huye hain and then Jab React ko pata chal jata hai ki Virtual DOM mein kya change hua hai, tab woh smartly decide karta hai ki Real DOM mein sirf woh parts update kiye jayein jo changes ko reflect karna hai. Isse, saare DOM ko har baar change karne ki jagah, sirf zaroori changes hi update hote hain. Aur yehi baat is process ko jaldi aur efficient banati hai compared to directly Real DOM ko har change pe update karna.

Toh, is tareeke se Virtual DOM helps React optimize performance by minimizing the number of changes needed in the Real DOM, making web apps faster and more efficient.


Popular posts from this blog

React Reconciliation

The React LifeCycle - Simple Language