From bbe818a61b6db36afaf6f18212d2890bfb428c93 Mon Sep 17 00:00:00 2001 From: Kanitkorn S Date: Wed, 10 Aug 2016 18:44:09 +0700 Subject: [PATCH 1/2] Fix wrong detection of proptype when isRequired is set --- src/components/PropTable.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/PropTable.js b/src/components/PropTable.js index f29d2fe25129..c3013c688814 100644 --- a/src/components/PropTable.js +++ b/src/components/PropTable.js @@ -8,6 +8,7 @@ for (let typeName in React.PropTypes) { } const type = React.PropTypes[typeName]; PropTypesMap.set(type, typeName); + PropTypesMap.set(type.isRequired, typeName); } const stylesheet = { From 03527f17b7b065f1c4bb454836aeb982642ee130 Mon Sep 17 00:00:00 2001 From: Kanitkorn S Date: Wed, 10 Aug 2016 19:07:57 +0700 Subject: [PATCH 2/2] Fix the file's coding style to pass the linting --- src/components/PropTable.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/PropTable.js b/src/components/PropTable.js index c3013c688814..e65c05ce0ef4 100644 --- a/src/components/PropTable.js +++ b/src/components/PropTable.js @@ -1,10 +1,10 @@ import React from 'react'; -import PropVal from './PropVal' +import PropVal from './PropVal'; const PropTypesMap = new Map(); -for (let typeName in React.PropTypes) { +for (const typeName in React.PropTypes) { if (!React.PropTypes.hasOwnProperty(typeName)) { - continue + continue; } const type = React.PropTypes[typeName]; PropTypesMap.set(type, typeName); @@ -16,11 +16,11 @@ const stylesheet = { marginLeft: -10, borderSpacing: '10px 5px', borderCollapse: 'separate', - } + }, }; export default class PropTable extends React.Component { - render () { + render() { const type = this.props.type; if (!type) { @@ -30,28 +30,28 @@ export default class PropTable extends React.Component { const props = {}; if (type.propTypes) { - for (let property in type.propTypes) { + for (const property in type.propTypes) { if (!type.propTypes.hasOwnProperty(property)) { - continue + continue; } const typeInfo = type.propTypes[property]; const propType = PropTypesMap.get(typeInfo) || 'other'; const required = typeInfo.isRequired === undefined ? 'yes' : 'no'; - props[property] = {property, propType, required}; + props[property] = { property, propType, required }; } } if (type.defaultProps) { - for (let property in type.defaultProps) { + for (const property in type.defaultProps) { if (!type.defaultProps.hasOwnProperty(property)) { - continue + continue; } const value = type.defaultProps[property]; if (value === undefined) { continue; } if (!props[property]) { - props[property] = {property}; + props[property] = { property }; } props[property].defaultValue = value; } @@ -81,7 +81,7 @@ export default class PropTable extends React.Component { {row.property} {row.propType} {row.required} - {row.defaultValue === undefined ? '-' : } + {row.defaultValue === undefined ? '-' : } ))} @@ -92,5 +92,5 @@ export default class PropTable extends React.Component { PropTable.displayName = 'PropTable'; PropTable.propTypes = { - type: React.PropTypes.func + type: React.PropTypes.func, };