- To render our React components, we need to
- Find a single "root" DOM node to attach our component, and
- Call
ReactDOM.render()
once.
- Thereafter we need not manipulate the DOM ourselves because everything will be managed by React DOM.
- Try the following example in
index.js
of yourcreate-react-app
app
// javascript
import ReactDOM from 'react-dom'
const element = <h1>Hello, world</h1>
ReactDOM.render(
element,
document.getElementById('root')
)
// html
<div id='root'></div>