top of page
Logo der Online Agentur mdwp


React.createElement() is a function in React JS library that allows you to create and return elements in the React structure. React elements are the smallest building blocks of a React app and they describe what you want to see on the screen.

React.createElement() function accepts three arguments: type, props, and children.

1. type: It is a string that specifies the type of DOM elements that you want to create. It can also be a React component type, which is either a function or a class.
2. props: It is an object of properties(key-value pairs) that is passed as the first parameter to the component function.
3. children: It includes the child elements of the element you are creating.


React.createElement('h1', {className: 'greeting'}, 'Hello, world!')

In the above code snippet, we are creating an h1 element with a CSS class name 'greeting'. The text inside the h1 tag is 'Hello, world!'. This JSX gets compiled into the JavaScript version shown above.

It's important to note that in real-world programming we do not often manually use React.createElement(), since JSX is easier and clearer to write especially in complex applications. However, understanding React.createElement() is essential to comprehend what happens under the hood when you use JSX.

bottom of page