react createelement functional component code example

Example 1: create functional component react

import React from 'react'; const App = () => {  const greeting = 'Hello Function Component!';   return <Headline value={greeting} />;}; const Headline = ({ value }) =>  <h1>{value}</h1>; export default App;

Example 2: react.createElement

//Below I use the React.createElement() function to create a virtual DOM
//representation of a <li> element node containing a text node of one (a.k.a.,
//React text) and an id of li1.

var reactNodeLi = React.createElement('li', {id:'li1'}, 'one');

Example 3: react createelement

class Greeting extends React.Component {
  render() {
    return <h1>Hello, {this.props.name}</h1>;
  }
}

Tags:

Misc Example