ReactDOM

The react-dom package provides DOM-specific methods that can be used at the top level of your app and as an escape hatch to get outside of the React model if you need to.

render()

ReactDOM.render(element, container[, callback])

Render a React element into the DOM in the supplied container and return a reference to the component (or returns null for stateless components).

If the React element was previously rendered into container, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React element.

hydrate()

ReactDOM.hydrate(element, container[, callback])

Same as render(), but is used to hydrate a container whose HTML contents were rendered by ReactDOMServer. React will attempt to attach event listeners to the existing markup.

findDOMNode()

ReactDOM.findDOMNode(component)
  • If this component has been mounted into the DOM, this returns the corresponding native browser DOM element.
  • This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements.
  • FindDOMNode only works on mounted components (that is, components that have been placed in the DOM).

createPortal()

ReactDOM.createPortal(child, container)

Creates a portal that provides a way to render children into a DOM node that exists outside the hierarchy of the DOM component.

unmountComponentAtNode()

ReactDOM.unmountComponentAtNode(container)
  • Remove a mounted React component from the DOM and clean up its event handlers and state.
  • If no component was mounted in the container, calling this function does nothing.
  • Returns true if a component was unmounted and false if there was no component to unmount.

ReactDOM — Structure map

Clickable & Draggable!

ReactDOM — Related pages: