How to Render React Component Without JSX?

Render React components without JSX using native APIs like React.createElement, helpful for dynamic rendering, advanced control, or simplified tooling.

Summarize with AI

Not enough time? get the key points instantly.

Learn how to write and render React components without JSX.

Why Render Without JSX?

  • No build step: Useful in environments where Babel or a build tool isn’t available.
  • Dynamic rendering: Enables rendering components by name or from a mapping.
  • Behind the scenes: Helps you understand how JSX is compiled.

Rendering a React Component Without JSX

Here’s how you can do typical JSX syntax with raw React.createElement for control and clarity.

Basic Example

import React from ‘react’;
import ReactDOM from ‘react-dom/client’;

 

function Greeting({ name }) {

  return React.createElement(‘h1’, null, ‘Hello ‘, React.createElement(‘i’, null, name), ‘. Welcome!’);

}

 

const root = ReactDOM.createRoot(document.getElementById(‘root’));

root.render(React.createElement(Greeting, { name: ‘Taylor’ }));

This code renders the same UI as , but without any JSX.

Dynamic Component Rendering (Mapping)

Suppose you want to render a component by name, not by direct import or JSX:

import React from ‘react’;import Login from ‘./Login’;

import Logout from ‘./Logout’;

 

const componentMap = {

  Login,

  Logout,

};

 

function Popup({ componentName }) {

  const ComponentToRender = componentMap[componentName];

  return React.createElement(

    ‘div’,

    null,

    ComponentToRender

      ? React.createElement(ComponentToRender)

      : ‘No component to display’

  );

}

This pattern is powerful for modals, popups, or dashboards where the component is chosen at runtime.

Also Read: ReactJS Development Services : Shift Towards the Appealing UI

Tips & Gotchas

  • Props: Pass them as the second argument to createElement (e.g., { name: ‘Taylor’ }).
  • Children: Pass as additional arguments after props; you can nest createElement calls for nested elements.
  • Don’t call function components directly: Always use React.createElement(Component) instead of Component()—the latter breaks hooks and context.
  • Shorthand: Assign const e = React.createElement; for less typing in large files.

Also Read: 

Advanced: No-JSX with Third-Party Helpers

  • react-hyperscript and hyperscript-helpers provide more concise, chainable syntax for large UIs without JSX.
  • No build step: Useful in environments where Babel or a build tool isn’t available.
  • Dynamic rendering: Enables rendering components by name or from a mapping.
  • Behind the scenes: Helps you understand how JSX is compiled.

Resources

Insights from our engineering leaders.

Our team shares practical insights on the technologies and engineering decisions shaping enterprise software today, grounded in real client work.

ReactJS

Filter Items Based On Multiple Properties

Why am I getting this problem? If you apply separate filters in sequence or only check one property at a time your code will match…