Skip to content

Instantly share code, notes, and snippets.

@paschalidi
Created December 17, 2019 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paschalidi/7219a2e8e61465247d7b6a35b0e5f6e6 to your computer and use it in GitHub Desktop.
Save paschalidi/7219a2e8e61465247d7b6a35b0e5f6e6 to your computer and use it in GitHub Desktop.
What is equivalent of the following using React.createElement?
const element = (
<h1 className="greeting">
Hello, world!
</h1>
);
// answer
const element = React.createElement(
'h1',
{className: 'greeting'},
'Hello, world!'
);
@W1zarDddD
Copy link

To create elements in React using React.createElement, you can specify the element type, its properties (or props), and its children (if any) as arguments.

@DevKyereboah
Copy link

explain this line of code to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment