Universal dependency update tool that fits into your workflows.
 
 
 
 
 
 
Go to file
vvo 0d4981713e 2.1.5 2016-01-05 16:53:45 +01:00
.eslintignore test(eslint): ignore -dist.js 2015-10-15 23:45:57 +02:00
.eslintrc test(stateless): skip anonymous stateless test 2015-12-09 15:40:54 +01:00
.gitignore chore(git): ignore more files 2015-10-16 21:51:35 +02:00
.npmignore chore(build): add full shrinkwrap 2015-10-15 23:46:06 +02:00
.travis.yml chore(ci): prune before shrinkwrap [ci skip] 2015-10-24 16:58:03 +02:00
AnonymousStatelessComponent.js test(stateless): skip anonymous stateless test 2015-12-09 15:40:54 +01:00
CHANGELOG.md 2.1.5 2016-01-05 16:53:45 +01:00
LICENSE First commit 2015-10-15 23:39:27 +02:00
README.md fix(whitespace): stop rendering it differently in SOME cases 2015-11-09 00:42:26 +01:00
index-test.js Extra new line with numbers 2016-01-05 09:44:55 +07:00
index.js Extra new line with numbers 2016-01-05 09:44:55 +07:00
mocha.opts First commit 2015-10-15 23:39:27 +02:00
npm-shrinkwrap.json 2.1.5 2016-01-05 16:53:45 +01:00
package.json 2.1.5 2016-01-05 16:53:45 +01:00

README.md

react-element-to-jsx-string

Version Build Status License Downloads

Turn a ReactElement into the corresponding JSX string.

Useful for unit testing and any other need you may think of.

Features:

  • supports nesting and deep nesting like <div a={{b: {c: {d: <div />}}}} />
  • props: supports string, number, function (inlined as prop={function noRefCheck() {}}), object, ReactElement (inlined), regex..
  • order props alphabetically
  • sort object keys in a deterministic order (o={{a: 1, b:2}} === o={{b:2, a:1}})
  • handle ref and key attributes, they are always on top of props
  • React's documentation indent style for JSX

Table of Contents generated with DocToc

Setup

npm install react-element-to-jsx-string --save[-dev]

Usage

import React from 'react';
import reactElementToJSXString from 'react-element-to-jsx-string';

console.log(reactElementToJSXString(<div a="1" b="2">Hello, world!</div>));
// <div
//   a="1"
//   b="2"
// >
//   Hello, world!
// </div>

Test

npm test
npm run test:watch

Build

npm run build
npm run build:watch

Thanks

alexlande/react-to-jsx was a good source of inspiration.

We built our own module because we had some needs like ordering props in alphabetical order.