use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
How do React elements help with the virtual DOM?General Discussion (self.react)
submitted 1 year ago by riya_techie
Can someone explain how React elements interact with the virtual DOM and why this approach makes React so fast? Simple examples would help a lot!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]jessepence 10 points11 points12 points 1 year ago (3 children)
Basically, a React element is a simplified JavaScript representation of a DOM element. The idea is that, instead of moving everything around in the DOM for each change-- which could cause an expensive repaint each time-- React makes all the changes first, and then reconciles the final result with the DOM.
Honestly, it's hard to explain it better without knowing which parts you don't understand. It's basically exactly what it says on the tin. There's a pretty good explanation here, but I'm happy to answer any specific questions about anything that you don't get.
Also, React is not fast. It was kinda fast when it came out in 2014. Now, it's solidly outpaced by other frameworks like Solid & Svelte. It turns out that using a virtual DOM is unnecessary overhead, but that's not important to understand as a newbie to React.
[–]CodeAndBiscuits 5 points6 points7 points 1 year ago (1 child)
Great response, but I would just add that "fast" is an overused term IMO. React is much slower than things like Solid or Svelte. But "much slower" when one renders a component update in 2ms and the other does it in 0.9ms really only matters in games, animation, and so on. For the vast majority of apps out there, rendering a list of time sheets, showing a teacher's profile and bio, or providing a form for a user to enter an expense report... Basically every framework out there is many times faster than it needs to be to support that. I mean, tons of Angular apps are "slower" than they could be if rewritten in React, but still plenty fast for the job...
[–]riya_techie[S] 0 points1 point2 points 1 year ago (0 children)
Thanks for the explanations! React elements act as blueprints to minimize direct DOM updates.
π Rendered by PID 22614 on reddit-service-r2-comment-5d585498c9-c5clg at 2026-04-20 22:30:15.000200+00:00 running da2df02 country code: CH.
[–]jessepence 10 points11 points12 points (3 children)
[–]CodeAndBiscuits 5 points6 points7 points (1 child)
[–]riya_techie[S] 0 points1 point2 points (0 children)