Skip to content

Commit

Permalink
Safety check before calling cloneElement (#1219)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Nov 5, 2020
1 parent 8e6e89b commit eed3802
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/source.js
Expand Up @@ -149,10 +149,13 @@ export default class Source<Props: SourceProps> extends PureComponent<Props> {
this._map.on('styledata', this._updateSource);
}
this._updateSource();
return React.Children.map(this.props.children, child =>
cloneElement(child, {
source: this.id
})
return React.Children.map(
this.props.children,
child =>
child &&
cloneElement(child, {
source: this.id
})
);
}

Expand Down

0 comments on commit eed3802

Please sign in to comment.