# react-vdom

> Retrieves the VDOM from a component

Latest version **0.6.2** (published 2015-12-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-vdom
pnpm add react-vdom
yarn add react-vdom
bun add react-vdom
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.2 |
| Published | 2015-12-29 |
| First published | 2014-09-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 70 |
| Author | Giulio Canti |
| Maintainers | gcanti |
| Keywords | react, vdom, test, react-component |

## Links

- npm: https://www.npmjs.com/package/react-vdom
- Repository: https://github.com/gcanti/react-vdom
- Issues: https://github.com/gcanti/react-vdom/issues
- npm.io page: https://npm.io/package/react-vdom

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 0.6.2 (latest) — 2015-12-29
- 0.6.1 — 2015-12-29
- 0.6.0 — 2015-11-13
- 0.5.0 — 2015-06-18
- 0.4.0 — 2015-05-11
- 0.3.0 — 2015-04-30
- 0.2.4 — 2015-04-29
- 0.2.3 — 2015-03-22
- 0.2.2 — 2014-12-27
- 0.2.1 — 2014-11-17
- 0.2.0 — 2014-11-17
- 0.1.3 — 2014-09-18
- 0.1.2 — 2014-09-17
- 0.1.1 — 2014-09-17
- 0.1.0 — 2014-09-05
- … 1 more at https://npm.io/package/react-vdom/versions

## README

[![build status](https://img.shields.io/travis/gcanti/react-vdom/master.svg?style=flat-square)](https://travis-ci.org/gcanti/react-vdom)
[![dependency status](https://img.shields.io/david/gcanti/react-vdom.svg?style=flat-square)](https://david-dm.org/gcanti/react-vdom)
![npm downloads](https://img.shields.io/npm/dm/react-vdom.svg)

# Important

If you are using React v0.13 you may want to install react-vdom v0.5.

# The Idea

I wrote this handy little library for testing purposes: you can extract the vdom from a React
component and test it against a JSON with simple tools like assert.deepEqual() and without a real DOM.
The extracted vdom has the following type definition:

```js
type Node = {
  tag: string,
  attrs: object<name, value>,
  children: undefined | null | Node | Array<Node>
}
```

If your component handle a private state, you can inject a state to test different configurations.

# Basic example

```js
var vdom = require('react-vdom');

// a simple component
var Counter = React.createClass({
  getInitialState: function () {
    return {count: 0};
  },
  render: function () {
    return (
      React.DOM.div(null, this.state.count)
    );
  }
});

var json = vdom(<Counter />);
console.log(json);
```

outputs

```json
{
  "tag": "div",
  "attrs": {},
  "children": 0
}
```

# Inject a state

```js
var state = {count: 1};
console.log(vdom(<Counter />, state));
```

outputs

```json
{
  "tag": "div",
  "attrs": {},
  "children": 1
}
```

# Setup

```sh
npm install react-vdom
```

# Api

```js
vdom(element, [state])
```

- `element` a ReactElement
- `state` inject a state

Returns a JSON containing a synthetic VDOM.

# License (MIT)

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