Skip to content

Commit

Permalink
Merge pull request #1430 from AvokaTech/master
Browse files Browse the repository at this point in the history
[Creatable] Handle null children prop gracefully
  • Loading branch information
JedWatson authored Jan 31, 2017
2 parents 7d4b8f0 + a40ca88 commit c6fa633
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Creatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,21 @@ const Creatable = React.createClass({

render () {
const {
children = defaultChildren,
newOptionCreator,
shouldKeyDownEventCreateNewOption,
...restProps
} = this.props;

let { children } = this.props;

// XXX: We can't use destructuring default values to set this, because if
// we're passed null for our 'children' prop, the default value will not be
// used as babel compiles destructuring default values to:
// value === undefined ? defaultValue : value
if (!children) {
children = defaultChildren;
}

const props = {
...restProps,
allowCreate: true,
Expand Down

0 comments on commit c6fa633

Please sign in to comment.