diff --git a/packages/addon-info/src/components/Story.js b/packages/addon-info/src/components/Story.js index 78c651b2f7c2..471375262700 100644 --- a/packages/addon-info/src/components/Story.js +++ b/packages/addon-info/src/components/Story.js @@ -249,7 +249,7 @@ export default class Story extends React.Component { } // depth-first traverse and collect types - function extract(children) { + const extract = children => { if (!children) { return; } @@ -260,13 +260,15 @@ export default class Story extends React.Component { if (children.props && children.props.children) { extract(children.props.children); } - if (typeof children === 'string' || typeof children.type === 'string') { + if (typeof children === 'string' || typeof children.type === 'string' || + (Array.isArray(this.props.propTablesExclude) && // also ignore excluded types + ~this.props.propTablesExclude.indexOf(children.type))) { return; } if (children.type && !types.has(children.type)) { types.set(children.type, true); } - } + }; // extract components from children extract(this.props.children); @@ -311,6 +313,7 @@ Story.propTypes = { context: PropTypes.object, info: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), propTables: PropTypes.arrayOf(PropTypes.func), + propTablesExclude: PropTypes.arrayOf(PropTypes.func), showInline: PropTypes.bool, showHeader: PropTypes.bool, showSource: PropTypes.bool, diff --git a/packages/addon-info/src/index.js b/packages/addon-info/src/index.js index a2f6f78081c3..ede94ae320ca 100644 --- a/packages/addon-info/src/index.js +++ b/packages/addon-info/src/index.js @@ -61,6 +61,7 @@ export default { showHeader: Boolean(options.header), showSource: Boolean(options.source), propTables: options.propTables, + propTablesExclude: options.propTablesExclude, styles: typeof options.styles === 'function' ? options.styles : s => s, mtrcConf, };