Skip to content

Commit

Permalink
fix AsyncCreatable options parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
unity committed Nov 18, 2016
1 parent da2f222 commit cddee25
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 cddee25

Please sign in to comment.