Skip to content

Instantly share code, notes, and snippets.

@rahulspace
Last active August 9, 2020 08:12
Show Gist options
  • Save rahulspace/4df582dfe36b4c88f64cc0794aab6eab to your computer and use it in GitHub Desktop.
Save rahulspace/4df582dfe36b4c88f64cc0794aab6eab to your computer and use it in GitHub Desktop.

React js

Create element

const e = React.createElement;

Create component

class HelloWorld extends React.Component {
  render () {
    return <h1>Hello, world!</h1>
  }
}

Render component

// Using html
ReactDOM.render(
  <h1>Hello, world!</h1>,
  document.getElementById('container')
)

// Using component
ReactDOM.render(
  e(HelloWorld),
  document.getElementById('container')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment