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

react-json-renderer

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-json-renderer - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

17

lib/converter.js

@@ -20,2 +20,6 @@ 'use strict';

var defaultProcessProps = function defaultProcessProps(props) {
return props;
};
var convertToObject = exports.convertToObject = function convertToObject(tree) {

@@ -25,2 +29,3 @@ var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

var replacers = params.replacers || {};
var processProps = params.processProps || defaultProcessProps;

@@ -68,5 +73,7 @@ var convertChild = function convertChild(child) {

var props = processProps(tree.props);
var replacer = replacers[name];
if (replacer) {
return convertComponent(replacer(tree.props), key);
return convertComponent(replacer(props), key);
}

@@ -76,7 +83,7 @@

if (type === 'string') {
children = convertChildren(tree.props.children);
children = convertChildren(props.children);
} else if (type === 'function') {
children = convertChildren(tree.type(tree.props));
children = convertChildren(tree.type(props));
} else if (type === 'class') {
var instance = new tree.type(tree.props);
var instance = new tree.type(props);
children = convertChildren(instance.render());

@@ -87,3 +94,3 @@ }

type: name,
props: _extends({}, tree.props, { children: children, key: key })
props: _extends({}, props, { children: children, key: key })
};

@@ -90,0 +97,0 @@ };

{
"name": "react-json-renderer",
"version": "0.1.0",
"version": "0.2.0",
"description": "Render React components to a JSON tree",

@@ -12,3 +12,3 @@ "main": "lib/index.js",

"build": "npm run build:clean && npm run build:compile && npm run build:flow && npm run build:types",
"flow": "flow",
"flow": "flow check",
"lint": "eslint ./src",

@@ -47,11 +47,11 @@ "jest": "jest",

"del-cli": "^1.1.0",
"eslint": "^4.2.0",
"eslint": "^4.3.0",
"eslint-config-prettier": "^2.3.0",
"eslint-plugin-flowtype": "^2.34.1",
"eslint-plugin-flowtype": "^2.35.0",
"eslint-plugin-prettier": "^2.1.2",
"eslint-plugin-react": "^7.1.0",
"flow-bin": "^0.49.1",
"flow-bin": "^0.51.1",
"flow-copy-source": "^1.2.0",
"jest": "^20.0.4",
"prettier": "^1.5.2",
"prettier": "^1.5.3",
"react": "^15.6.1",

@@ -58,0 +58,0 @@ "react-test-renderer": "^15.6.1"

@@ -27,2 +27,3 @@ # react-json-renderer

params?: {
processProps?: (props: Object) => Object,
replacers?: {

@@ -43,2 +44,3 @@ [string]: (props: Object) => React.Element<*>,

params?: {
processProps?: (props: Object) => Object,
replacers?: {

@@ -45,0 +47,0 @@ [string]: (props: Object) => React.Element<*>,

@@ -16,5 +16,8 @@ // @flow

type ConvertParams = {
processProps?: (props: Object) => Object,
replacers?: { [string]: Replacer },
}
const defaultProcessProps = (props: Object) => props
export const convertToObject = (

@@ -25,2 +28,3 @@ tree: Element<*>,

const replacers = params.replacers || {}
const processProps = params.processProps || defaultProcessProps

@@ -73,5 +77,7 @@ const convertChild = (child: ElementChild): ConvertedChild => {

const props = processProps(tree.props)
const replacer = replacers[name]
if (replacer) {
return convertComponent(replacer(tree.props), key)
return convertComponent(replacer(props), key)
}

@@ -81,7 +87,7 @@

if (type === 'string') {
children = convertChildren(tree.props.children)
children = convertChildren(props.children)
} else if (type === 'function') {
children = convertChildren(tree.type(tree.props))
children = convertChildren(tree.type(props))
} else if (type === 'class') {
const instance = new tree.type(tree.props)
const instance = new tree.type(props)
children = convertChildren(instance.render())

@@ -92,3 +98,3 @@ }

type: name,
props: { ...tree.props, children, key },
props: { ...props, children, key },
}

@@ -95,0 +101,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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