Socket
Book a DemoInstallSign in
Socket

react-dom-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dom-wrapper

A (somewhat) helpful wrapper function for creating React elements

latest
Source
npmnpm
Version
4.1.0
Version published
Maintainers
1
Created
Source

react-dom-wrapper Build Status

Convert an array of element data to react elements. Prettier than JSX, less verbose than using React.DOM directly. Inspired by (though not as pretty as) Hiccup.

Installation

$ npm install [--save] react-dom-wrapper

Usage

var DOM = require('react-dom-wrapper');

var element = DOM([
    'div#wrapper',
    { className: 'asd' },
    ['span.message.important', 'hello', ['span.bold', name]],
    [CustomComponent, { customProp: 'hello' }],
    [
        'ul',
        arrayOfThings.map(function(thing) {
            return ['li', { key: thing.id }, thing.value]
        })
    ]
]);

React.render(element, mountNode);

Using a custom React

If you want to use a different version of React entirely, you can do var DOM = require('react-dom-wrapper/react-dom-wrapper')(myCustomReact).

Element spec

An element is an array consisting of:

  • Element type (string or React component)
  • Optional props object
  • Zero or more children (string, element spec, React element, or an array (can even be nested) of any of those)

Testing

There are test! Buster is used. npm test runs the test, npm run autotest watches the files and runs tests automatically.

License

MIT

Keywords

react

FAQs

Package last updated on 26 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.