Skip to content

Commit

Permalink
Merge pull request JedWatson#1374 from hull/master
Browse files Browse the repository at this point in the history
fix AsyncCreatable options parsing
  • Loading branch information
JedWatson authored Nov 18, 2016
2 parents da2f222 + cddee25 commit a97d5fd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/AsyncCreatable.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import React from 'react';
import Select from './Select';

function reduce(obj, props = {}){
return Object.keys(obj)
.reduce((props, key) => {
const value = obj[key];
if (value !== undefined) props[key] = value;
return props;
}, props);
}

const AsyncCreatable = React.createClass({
displayName: 'AsyncCreatableSelect',

Expand All @@ -11,12 +20,15 @@ const AsyncCreatable = React.createClass({
<Select.Creatable {...this.props}>
{(creatableProps) => (
<Select
{...asyncProps}
{...creatableProps}
{...reduce(asyncProps, reduce(creatableProps, {}))}
onInputChange={(input) => {
creatableProps.onInputChange(input);
return asyncProps.onInputChange(input);
}}
ref={(ref) => {
creatableProps.ref(ref);
asyncProps.ref(ref);
}}
/>
)}
</Select.Creatable>
Expand Down

0 comments on commit a97d5fd

Please sign in to comment.