The null is React.createElement is reserved for giving attribute values to the element. If you have none to pass then you put in a null, else you pass the attribute in a javascript object form. See example below. Here className is used for class as that is what is used in jsx to define html class.
import React, { Component } from 'react';
import './App.css';
class App extends Component {
render() {
return React.createElement('div', { className: "App" }, React.createElement('h1', null,'Title'));
}
}
export default App;
This example outputs
<div class="App"><h1>Title</h1></div>
Comments
Post a Comment