New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-element-to-jsx-string

Package Overview
Dependencies
Maintainers
12
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-element-to-jsx-string - npm Package Compare versions

Comparing version

to
6.4.0

11

CHANGELOG.md

@@ -0,1 +1,12 @@

<a name="6.4.0"></a>
# [6.4.0](https://github.com/algolia/react-element-to-jsx-string/compare/v6.3.0...v6.4.0) (2017-04-24)
### Features
* **functionValue:** format functions output the way you want ([460e0cc](https://github.com/algolia/react-element-to-jsx-string/commit/460e0cc))
* **React:** support 15.5+ ([1a99024](https://github.com/algolia/react-element-to-jsx-string/commit/1a99024))
<a name="6.3.0"></a>

@@ -2,0 +13,0 @@ # [6.3.0](https://github.com/algolia/react-element-to-jsx-string/compare/v6.2.0...v6.3.0) (2017-03-06)

35

index-dist.js

@@ -19,2 +19,4 @@ 'use strict';

var _testUtils = require('react-dom/test-utils');
var _collapseWhiteSpace = require('collapse-white-space');

@@ -42,2 +44,6 @@

var defaultFunctionValue = function defaultFunctionValue(fn) {
return fn;
};
function reactElementToJSXString(ReactElement) {

@@ -52,2 +58,4 @@ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},

showFunctions = _ref$showFunctions === undefined ? false : _ref$showFunctions,
_ref$functionValue = _ref.functionValue,
functionValue = _ref$functionValue === undefined ? defaultFunctionValue : _ref$functionValue,
_ref$tabStop = _ref.tabStop,

@@ -73,3 +81,3 @@ tabStop = _ref$tabStop === undefined ? 2 : _ref$tabStop,

return Element;
} else if (!(0, _react.isValidElement)(Element)) {
} else if (!(0, _testUtils.isElement)(Element)) {
throw new Error('react-element-to-jsx-string: Expected a ReactElement,\ngot `' + (typeof Element === 'undefined' ? 'undefined' : _typeof(Element)) + '`');

@@ -217,3 +225,3 @@ }

function getValueType(value) {
if ((0, _react.isValidElement)(value)) {
if ((0, _testUtils.isElement)(value)) {
return 'element';

@@ -233,8 +241,14 @@ }

function isFunction(value) {
return typeof value === 'function';
}
function formatValue(value, inline, lvl) {
var wrapper = '__reactElementToJSXString__Wrapper__';
if (isFunction(value)) {
return functionValue(showFunctions === false && functionValue === defaultFunctionValue ? function noRefCheck() {} // eslint-disable-line prefer-arrow-callback
: value);
}
if (typeof value === 'function' && !showFunctions) {
return function noRefCheck() {};
} else if ((0, _react.isValidElement)(value)) {
if ((0, _testUtils.isElement)(value)) {
// we use this delimiter hack in cases where the react element is a property

@@ -247,3 +261,6 @@ // of an object from a root prop

// otherwise, the element would be surrounded by quotes: <div a={{b: '<div />'}} />
return '<' + wrapper + '>' + toJSXString({ ReactElement: value, inline: true }) + '</' + wrapper + '>';
return '<' + wrapper + '>' + toJSXString({
ReactElement: value,
inline: true
}) + '</' + wrapper + '>';
} else if ((0, _isPlainObject2.default)(value) || Array.isArray(value)) {

@@ -269,3 +286,3 @@ return '<' + wrapper + '>' + stringifyObject(value, inline, lvl) + '</' + wrapper + '>';

obj = (0, _traverse2.default)(obj).map(function (value) {
if ((0, _react.isValidElement)(value) || this.isLeaf) {
if ((0, _testUtils.isElement)(value) || this.isLeaf) {
this.update(formatValue(value, inline, lvl));

@@ -291,4 +308,4 @@ }

return ReactElement.type.displayName || ReactElement.type.name || ( // function name
typeof ReactElement.type === 'function' ? // function without a name, you should provide one
'No Display Name' : ReactElement.type);
typeof ReactElement.type === 'function' // function without a name, you should provide one
? 'No Display Name' : ReactElement.type);
}

@@ -295,0 +312,0 @@

{
"name": "react-element-to-jsx-string",
"version": "6.3.0",
"version": "6.4.0",
"description": "Turn a ReactElement into the corresponding JSX string.",
"main": "index-dist.js",
"scripts": {
"precommit": "lint-staged",
"prepublish": "npm run build",

@@ -14,2 +15,8 @@ "build": "babel index.js -o index-dist.js",

},
"lint-staged": {
"*.js": [
"prettier --write --single-quote --trailing-comma es5",
"git add"
]
},
"author": {

@@ -22,24 +29,29 @@ "name": "Algolia, Inc.",

"devDependencies": {
"babel-cli": "^6.23.0",
"babel-eslint": "^7.1.1",
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-plugin-lodash": "^3.2.11",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.23.0",
"conventional-changelog-cli": "^1.2.0",
"doctoc": "^1.2.0",
"eslint": "^3.16.1",
"eslint-config-algolia": "^6.0.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.24.1",
"conventional-changelog-cli": "^1.3.1",
"doctoc": "^1.3.0",
"eslint": "^3.19.0",
"eslint-config-algolia": "^7.0.2",
"eslint-config-prettier": "^1.7.0",
"eslint-import-resolver-webpack": "^0.8.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jasmine": "^2.2.0",
"eslint-plugin-react": "^6.10.0",
"eslint-plugin-jest": "^19.0.1",
"eslint-plugin-react": "^6.10.3",
"expect": "^1.14.0",
"json": "^9.0.4",
"husky": "^0.13.3",
"json": "^9.0.6",
"lint-staged": "^3.4.0",
"mocha": "^3.2.0",
"prettier": "^1.2.2",
"react": "^15.4.2",
"react-addons-test-utils": "^15.4.2",
"react-dom": "^15.4.2",
"webpack": "^1.14.0"
"react-dom": "^15.5.4",
"react-test-renderer": "^15.5.4",
"webpack": "^2.4.1"
},

@@ -54,5 +66,5 @@ "peerDependencies": {

"sortobject": "^1.0.0",
"stringify-object": "^3.1.0",
"stringify-object": "^3.2.0",
"traverse": "^0.6.6"
}
}

@@ -89,2 +89,9 @@ # react-element-to-jsx-string

**options.functionValue: function, default `(fn) => fn`**
Allows you to override the default formatting of function values.
`functionValue` receives the original function reference as input
and should send any value as output.
**options.tabStop: number, default 2**

@@ -91,0 +98,0 @@

Sorry, the diff of this file is not supported yet