React DOM Factories

1.0.2 · abandoned · verified Sun Apr 19

react-dom-factories is a legacy add-on package, currently at version 1.0.2, that provides pre-configured DOM factory methods for creating React elements. These factories, such as `DOM.div` or `DOM.p`, were originally part of React itself prior to version 16.0.0. The package was created to serve applications that depended on these specific factory functions, allowing them to continue functioning after React itself removed them. However, its use is strongly discouraged in modern React development. Developers are advised to use JSX for declarative UI creation or `React.createElement` (which `createFactory` wraps) instead. The package is considered abandoned, has seen no updates since its initial release, and is not designed for current React versions or development practices, nor does it receive any ongoing maintenance or new releases.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the `DOM` object from `react-dom-factories` to create a basic React component, then render it to the DOM using `ReactDOM.render`. It showcases the syntax for creating elements with properties and children, mimicking the pre-JSX factory pattern.

import ReactDOM from 'react-dom';
import DOM from 'react-dom-factories';

/**
 * A simple functional component using react-dom-factories to create elements.
 * This approach is largely superseded by JSX in modern React development.
 */
function LegacyApp() {
  const greetingMessage = DOM.p(null, 'Hello from react-dom-factories!');
  const container = DOM.div({ className: 'legacy-container' }, 
    DOM.h1(null, 'Legacy React App'), 
    greetingMessage
  );
  return container;
}

// Assuming an element with id 'app' exists in your HTML document
const appRoot = document.getElementById('app');

if (appRoot) {
  ReactDOM.render(LegacyApp(), appRoot);
  console.log('Legacy React App rendered using react-dom-factories.');
} else {
  console.error("Target element with id 'app' not found. Please ensure your HTML has <div id='app'></div>.");
}

view raw JSON →