Search⌘ K

Alternatives to the react.createElement() Method

Explore alternatives to react.createElement() to write clearer React components. Understand how JSX improves readability and how tagged template literals via libraries like htm allow you to write readable React elements without compilation.

Repeated usage of react.createElement() might compromise the readability of our React components. In fact, nesting many invocations of the react.createElement() method, even with our h() alias, will make it hard to understand the HTML structure we want our components to render.

For this reason, it’s not very common to use react.createElement() directly. To address this problem, the React team offers and encourages an alternative syntax called JSX.

Using JSX

JSX is a superset of JavaScript that allows us to embed HTML-like code into JavaScript code. JSX makes the creation ...