4 ms·
If someone can explain to me one thing I still do not grasp about react, even though I have done some small websites and apps in react. I understand the virtual
by yawaworht1978 5y ago
If someone can explain to me one thing I still do not grasp about react, even though I have done some small websites and apps in react. I understand the virtual Dom concept and only refreshing the necessary DOM components.
But how is that much different than an ajax update?
I understand ajax causes a request or more, but it only refreshes part of the DOM, right? Or does it cause a full re flow/paint?
- schneidmaster 5y agoAJAX (Asynchronous Javascript and XML) is purely orthogonal to DOM updates. An AJAX request is just a network request initiated asynchronously via some Javascript on the page, as opposed to a request initiated synchronously when a user clicks a link or submits a form. Response data from an AJAX request could be used to make a direct DOM mutation, update React state, log to the console, or anything else the developer wants.
- stevula 5y agoAJAX does not update the DOM at all. You have to write some JS to mutate the DOM based on the response data, which is one of the things React is good at.