# react-data-markup

> Data syntax for React.js markup

Latest version **1.1.1** (published 2019-07-19) · 0 weekly downloads

## Install

```sh
npm install react-data-markup
pnpm add react-data-markup
yarn add react-data-markup
bun add react-data-markup
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2019-07-19 |
| First published | 2017-11-04 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 65.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | dferens |
| Keywords | react, react.js, markup, dom |

## Links

- npm: https://www.npmjs.com/package/react-data-markup
- Repository: https://github.com/dferens/react-data-markup
- Issues: https://github.com/dferens/react-data-markup/issues
- npm.io page: https://npm.io/package/react-data-markup

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2019-07-19
- 1.1.0 — 2019-04-22
- 2.0.0 — 2019-03-08
- 1.0.3 — 2018-12-17
- 1.0.2 — 2018-12-14
- 1.0.1 — 2017-11-04
- 1.0.0 — 2017-11-04

## README

# react-data-markup [![Build Status](https://travis-ci.org/dferens/react-data-markup.svg?branch=master)](https://travis-ci.org/dferens/react-data-markup) ![npm version](https://img.shields.io/npm/v/react-data-markup.svg)

Write React.js markup with arrays & objects, inspired by [react-hyperscript](https://github.com/mlmorg/react-hyperscript) and [rum](https://github.com/tonsky/rum).

## Importing

```es6
import DataMarkup from 'react-data-markup'; // ES6
var DataMarkup = require('react-data-markup'); // ES5 with npm
```

If you prefer a <script> tag, you can get it from window.DataMarkup global:

```html
<!-- development version -->
<script src="https://unpkg.com/react-data-markup/react-data-markup.js"></script>
```

## Form syntax

```
[<tag-n-function>, <props>?, <children>*, ...]
```
- **\<tag-n-function\>** `String|Object` - function, component, or string in a format 'tag#id.class'
- **\<props\>** `Object` *(optional)* - An object containing the props you'd like to set on the element
- **\<children\>** `Array` - Zero or more forms or a strings. This will create child elements or a text node, respectively.

## Usage

```javascript
var DataMarkup = window.DataMarkup;    

// Use `DataMarkup.wrapFunction` for functional components
var FunctionalComponent = DataMarkup.wrapFunction(function(props) {
  return (
    ['p', props.x * 2]
  )
});

// Use `DataMarkup.createClass` to get `render` automatically wrapped
var AnotherComponent = DataMarkup.createClass({
  render: function() {
    return ['p', 'Hello world!', this.props.children]            
  }
});

var MainComponent = DataMarkup.createClass({
  render: function render() {
    return (
        ['.example',
            ['h1#heading', 'These are arrays'],
            ['h2', 'creating React.js markup'],
            [FunctionalComponent, {x: 5}],
            [AnotherComponent, {foo: 'bar'},
                ['li', {href: 'http://whatever.com'}, 'One list item'],
                ['li', 'Another list item']
            ]    
        ]
    );                    
  }
});    
```

## API

#### `DataMarkup.createClass(classSpec)`

Creates React component, which transforms markup returned by `render` into React's elements.

#### `DataMarkup.wrapFunction(fn)`

Returns function, which calls `fn` and transforms it's result.

- **fn** `Function`

#### `DataMarkup.transform(form)`

Parses array markup and returns React elements.

- **form** `Array`

---
_Source: https://npm.io/package/react-data-markup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
