diff --git a/src/AsyncCreatable.js b/src/AsyncCreatable.js
index dddb99af8c..b082f5af77 100644
--- a/src/AsyncCreatable.js
+++ b/src/AsyncCreatable.js
@@ -1,17 +1,9 @@
import React from 'react';
+import PropTypes from 'prop-types';
import Select from './Select';
import Async from './Async';
import Creatable from './Creatable';
-function reduce(obj, props = {}){
- return Object.keys(obj)
- .reduce((props, key) => {
- const value = obj[key];
- if (value !== undefined) props[key] = value;
- return props;
- }, props);
-}
-
class AsyncCreatableSelect extends React.Component {
focus () {
@@ -21,27 +13,39 @@ class AsyncCreatableSelect extends React.Component {
render () {
return (
- {(asyncProps) => (
-
- {(creatableProps) => (
-
- )}
+ {({ 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 (
+
+ );
+};
+
+AsyncCreatableSelect.PropTypes = {
+ children: PropTypes.func.isRequired, // Child function responsible for creating the inner Select component; (props: Object): PropTypes.element
+};
+
+AsyncCreatableSelect.defaultProps = {
+ children: defaultChildren,
+};
+
export default AsyncCreatableSelect;
diff --git a/src/Creatable.js b/src/Creatable.js
index 8ddbba63ea..4d87a305a1 100644
--- a/src/Creatable.js
+++ b/src/Creatable.js
@@ -116,7 +116,7 @@ class CreatableSelect extends React.Component {
this.inputValue = input;
if (onInputChange) {
- this.inputValue = onInputChange(input);
+ this.inputValue = onInputChange(input);
}
return this.inputValue;