From a40ca88e6d45e84b04ffee6e89f6f817bb83e2b9 Mon Sep 17 00:00:00 2001 From: Jack Coulter Date: Wed, 14 Dec 2016 15:35:02 +1100 Subject: [PATCH] fix(Creatable): Handle null "children" prop gracefully --- src/Creatable.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Creatable.js b/src/Creatable.js index 3f2f473e28..7f622baa30 100644 --- a/src/Creatable.js +++ b/src/Creatable.js @@ -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,