Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
Merge pull request #56 from kadirahq/fix-undefined-type
Browse files Browse the repository at this point in the history
Handle false values for type
  • Loading branch information
Muhammed Thanish authored Aug 14, 2016
2 parents d1d30e1 + 06f0d76 commit d4e3e48
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/components/Story.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,23 @@ export default class Story extends React.Component {
});
}

// depth-first traverse and collect types
function extract(children) {
const type = children.type;

if (!children) {
return;
}
if (Array.isArray(children)) {
children.forEach(extract);
return;
}
if (children.props && children.props.children) {
extract(children.props.children);
}
if (typeof children === 'string' || typeof children.type === 'string') {
return;
}

if (!types.has(type)) {
types.set(type, true);
}
if (children.props.children) {
extract(children.props.children);
if (children.type && !types.has(children.type)) {
types.set(children.type, true);
}
}

Expand Down

0 comments on commit d4e3e48

Please sign in to comment.