Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-element-to-string

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.0.0 to 1.0.1

6

index.js

@@ -18,3 +18,7 @@ var React = require('react');

function showName(element) {
return element.type.displayName || element.type.name || element.type;
var type = element.type;
if (type.displayName) return type.displayName;
if (type.name) return type.name;
if (typeof type == 'string') return type;
return 'Unknown';
}

@@ -21,0 +25,0 @@

2

package.json
{
"name": "react-element-to-string",
"version": "1.0.0",
"version": "1.0.1",
"description": "Convert a ReactElement into a nice string useful for debugging",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -83,2 +83,19 @@ var React = require('react');

it('should handle function children', function() {
function Func() { return <hr />; }
expect(str(<Basic><Func /></Basic>))
.to.eql('<Basic>\n <Func />\n</Basic>');
});
it('should handle component without displayName children', function() {
var A = (function() {
// eslint-disable-next-line react/display-name
return React.createClass({
render: function() { return null; }
});
})();
expect(str(<Basic><A /></Basic>))
.to.eql('<Basic>\n <Unknown />\n</Basic>');
});
it('should show ReactElement with text children', function() {

@@ -85,0 +102,0 @@ expect(str(<Basic>Stuff{"&"}Nonsense</Basic>))

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc