From 5cf7886760a931739d996a0209f74400b53eb642 Mon Sep 17 00:00:00 2001 From: Daniel Heath Date: Tue, 8 Nov 2016 10:55:05 +1100 Subject: [PATCH 1/4] Refactor: Flatten loop over a single item This abstraction might be justified if there were 3+ copies of the loop, but for a single item it's added overhead + confusion to no benefit. --- src/Async.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Async.js b/src/Async.js index 17e949db0d..e748a9aa6e 100644 --- a/src/Async.js +++ b/src/Async.js @@ -67,14 +67,11 @@ export default class Async extends Component { } componentWillUpdate (nextProps, nextState) { - const propertiesToSync = ['options']; - propertiesToSync.forEach((prop) => { - if (this.props[prop] !== nextProps[prop]) { - this.setState({ - [prop]: nextProps[prop] - }); - } - }); + if (this.props.options !== nextProps.options) { + this.setState({ + options: nextProps.options + }); + } } clearOptions() { From 33ebaf70b8c3647b02f803cd1c3e6d474c7916a2 Mon Sep 17 00:00:00 2001 From: Daniel Heath Date: Tue, 8 Nov 2016 11:49:17 +1100 Subject: [PATCH 2/4] Creatable calls through to onInputChange prop if provided Previously, if you provided an `onInputChange` prop to a `Creatable` it would be silently discarded. After this change you can use Creatable and also get an event when the user types input. --- src/AsyncCreatable.js | 4 ---- src/Creatable.js | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/AsyncCreatable.js b/src/AsyncCreatable.js index 12b8ad540c..4bd3099b8b 100644 --- a/src/AsyncCreatable.js +++ b/src/AsyncCreatable.js @@ -13,10 +13,6 @@ const AsyncCreatable = React.createClass({ - )} - - )} + {({ref, ...asyncProps}) => { + const asyncRef = ref; + return + {({ref, ...creatableProps}) => { + const creatableRef = ref; + return this.props.children({ + ...creatableProps, + ref: (select) => { + creatableRef(select); + asyncRef(select); + this.select = select; + } + }); + }} + ; + }} ); } }); +function defaultChildren (props) { + return ( +