react-json-renderer
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -48,3 +48,3 @@ 'use strict'; | ||
} | ||
if (typeof child === 'number' || typeof child === 'string') { | ||
if (typeof child === 'boolean' || typeof child === 'number' || typeof child === 'string') { | ||
return child; | ||
@@ -51,0 +51,0 @@ } |
@@ -36,3 +36,3 @@ 'use strict'; | ||
} | ||
if (typeof c === 'number' || typeof c === 'string') { | ||
if (typeof c === 'boolean' || typeof c === 'number' || typeof c === 'string') { | ||
return c; | ||
@@ -57,3 +57,3 @@ } | ||
if (children) { | ||
if (children != null) { | ||
props.children = Array.isArray(children) // eslint-disable-line react/prop-types | ||
@@ -70,4 +70,4 @@ ? children.map(createChild) : createChild(children); | ||
var Renderer = exports.Renderer = function (_Component) { | ||
_inherits(Renderer, _Component); | ||
var Renderer = exports.Renderer = function (_PureComponent) { | ||
_inherits(Renderer, _PureComponent); | ||
@@ -89,3 +89,3 @@ function Renderer() { | ||
var obj = void 0; | ||
if (tree) obj = tree;else if (json) obj = JSON.parse(json); | ||
if (tree) obj = tree;else if (json) obj = JSON.parse(json); // flowlint-line sketchy-null-string:off | ||
@@ -97,2 +97,2 @@ return obj ? renderFromObject(obj, params) : null; | ||
return Renderer; | ||
}(_react.Component); | ||
}(_react.PureComponent); |
{ | ||
"name": "react-json-renderer", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "Render React components to a JSON tree", | ||
@@ -23,7 +23,3 @@ "main": "lib/index.js", | ||
}, | ||
"keywords": [ | ||
"react", | ||
"json", | ||
"renderer" | ||
], | ||
"keywords": ["react", "json", "renderer"], | ||
"author": "Paul Le Cam <paul@ulem.net>", | ||
@@ -39,16 +35,16 @@ "license": "MIT", | ||
"devDependencies": { | ||
"babel-cli": "^6.24.1", | ||
"babel-core": "^6.25.0", | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^7.2.3", | ||
"babel-jest": "^20.0.3", | ||
"babel-preset-latest": "^6.24.1", | ||
"babel-preset-env": "^1.6.0", | ||
"babel-preset-react": "^6.24.1", | ||
"babel-preset-stage-1": "^6.24.1", | ||
"del-cli": "^1.1.0", | ||
"eslint": "^4.3.0", | ||
"eslint": "^4.4.1", | ||
"eslint-config-prettier": "^2.3.0", | ||
"eslint-plugin-flowtype": "^2.35.0", | ||
"eslint-plugin-prettier": "^2.1.2", | ||
"eslint-plugin-react": "^7.1.0", | ||
"flow-bin": "^0.51.1", | ||
"eslint-plugin-prettier": "^2.2.0", | ||
"eslint-plugin-react": "^7.2.1", | ||
"flow-bin": "^0.53.0", | ||
"flow-copy-source": "^1.2.0", | ||
@@ -55,0 +51,0 @@ "jest": "^20.0.4", |
@@ -25,5 +25,5 @@ # react-json-renderer | ||
convertToObject( | ||
tree: React.Element<*>, | ||
tree: React.Element<any>, | ||
params?: { | ||
processMeta?: (tree: React.Element<*>) => ({ | ||
processMeta?: (tree: React.Element<any>) => ({ | ||
name: string, | ||
@@ -45,3 +45,3 @@ type: 'function' | 'string' | 'unknown', | ||
params?: { | ||
processMeta?: (tree: React.Element<*>) => ({ | ||
processMeta?: (tree: React.Element<any>) => ({ | ||
name: string, | ||
@@ -65,5 +65,5 @@ type: 'function' | 'string' | 'unknown', | ||
components?: { | ||
[type: string]: Class<React.Component<*, *, *>> | (props: Object) => React.Element<*>, | ||
[type: string]: React.ComponentType<any>, | ||
}, | ||
fallback?: Class<React.Component<*, *, *>> | (props: Object) => React.Element<*>, | ||
fallback?: React.ComponentType<any>, | ||
}, | ||
@@ -70,0 +70,0 @@ ): React.Element<*> |
20
types.js
// @flow | ||
import type { Component, Element } from 'react' | ||
import type { Component, Element, Node } from 'react' | ||
export type FunctionComponent = (props: Object) => Element<*> | ||
export type ElementChild = void | null | boolean | number | string | Element<*> | ||
export type ClassComponent = Class<Component<*, *, *>> | ||
export type AnyComponent = FunctionComponent | ClassComponent | ||
export type ElementChild = void | number | string | Element<*> | ||
export type ElementChildren = ElementChild | Array<ElementChild> | ||
export type ElementProps = { | ||
children?: ElementChildren, | ||
children?: Node, | ||
[key: string]: mixed, | ||
} | ||
export type ConvertedChild = void | number | string | ConvertedElement | ||
export type ConvertedChild = | ||
| void | ||
| null | ||
| boolean | ||
| number | ||
| string | ||
| ConvertedElement | ||
@@ -22,0 +22,0 @@ export type ConvertedChildren = ConvertedChild | Array<ConvertedChild> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
166775
14
201