React.createElement 1

React.createElement

class Hello extends React.Component {
  render() {
    return React.createElement('div', null, `Hello ${this.props.toWhat}`);
  }
}

ReactDOM.render(
  React.createElement(Hello, {toWhat: 'World'}, null),
  document.getElementById('root')
);

Here is what the above code is Doing:
1. We’re importing React and ReactDOM.
2. We’re creating a React component called Hello.
3. We’re rendering an instance of that component to the DOM using ReactDOM.render().

The ReactDOM.render() function takes two arguments:
1. What to render (a React element)
2. Where to render it (a DOM node)

The ReactDOM.render() function creates a React component, creates an instance of that component, and inserts it into the DOM.

The ReactDOM.render() function is the most common way to render JSX.

The ReactDOM.render() function can also take an optional third argument: a callback function.

The callback function will be called after the component is rendered.

Similar Posts