Rendering React Elements
The ReactDOM.render()
method takes three parameters: ReactElement
, a regular DOMElement
, and a callback function:
ReactDOM.render(ReactElement, DOMElement, callback);
ReactElement
is a root element in the tree of ReactNode
s that you've created. A regular DOMElement
is a container DOM node for that tree. The callback
is a function executed after the tree is rendered or updated. It's important to note that if this ReactElement
was previously rendered to a parent DOM Element
, then ReactDOM.render()
will perform an update on the already rendered DOM tree and only mutate the DOM as it is necessary to reflect the latest version of the ReactElement
. This is why a virtual DOM requires fewer DOM mutations.
So far, we've assumed that ...
Get React: Building Modern Web Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.