The
render()
format of the method is as follows:
ReactDOM.render(element, container[, callback])
render()
method is used in the supplied container parameters
container
render a React element in the
element
.
render()
method returns a reference to the component (or for stateless components
null
).
If the React element is already in the
container
, which will update it and change the DOM only if necessary to map the latest React elements.
If an optional callback function is provided
callback
the callback willbe performed after the component is rendered or updated
The following examples are in use
render()
the method is in
id="root"
render React elements in the container of
Header
: 3.15.1. Example ¶
classHeaderextendsReact.Component{render(){return(<h1>Rookie Tutorial -
Learning is not only about technology, but also about dreams!</h1>);}}ReactDOM.render(<Header/>,document.getElementById('root'));