how to create element in react using js code example
Example 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')
);
Example 2: react createelement
class Greeting extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}