react-conditional-component
Advanced tools
Comparing version 0.1.4 to 0.1.5
{ | ||
"name": "react-conditional-component", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "This component displays its children only if they satisfy their predicate", | ||
"main": "react-conditional-component.jsx", | ||
"main": "react-conditional-component.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"prepublish": "node_modules/.bin/babel --stage 1 ./react-conditional-component.jsx --out-file ./react-conditional-component.js" | ||
}, | ||
@@ -26,4 +27,7 @@ "repository": { | ||
"peerDependencies": { | ||
"react": "0.12.x" | ||
"react": ">= 0.11.1 < 1" | ||
}, | ||
"devDependencies": { | ||
"babel": "^5.6.7" | ||
} | ||
} |
@@ -0,9 +1,13 @@ | ||
/** | ||
* @jsx React.DOM | ||
*/ | ||
var React = require('react'); | ||
module.exports = React.createClass({ | ||
displayName: 'ConditionalComponent', | ||
render: function() { | ||
var value = this.props.value; | ||
var shown = []; | ||
let value = this.props.value; | ||
let shown = []; | ||
React.Children.forEach(this.props.children, function(child) { | ||
var show = true; | ||
let show = true; | ||
if (show && child.props.showIfDefined) { | ||
@@ -10,0 +14,0 @@ show = typeof value !== 'undefined'; |
19485
12
113
1