React.createElement example
Example 1: react.createElement
var reactNodeLi = React.createElement('li', {id:'li1'}, 'one');
Example 2: React create element
React.createElement("div", null, "Hello React!")
Example 3: 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 4: react.createelement
React.createElement(
type,
[props],
[...children]
)
Example 5: React.createElement
const e = React.createElement;
ReactDOM.render(
e('div', null, 'Hello World'),
document.getElementById('root')
);
Example 6: react createelement
class Greeting extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}