raynor85 / react-native-material-selectize

A React Native component inspired to Selectize which follows Material Design guidelines.
MIT License
55 stars 32 forks source link

Feature Request: Simple onChange() callback prop #5

Closed grailian closed 6 years ago

grailian commented 6 years ago

Hello!

I think it would be very convenient to add an onChange prop to <Selectize />. Here is my desired used case:

<Selectize
    label={this.props.displayName}
    itemId="value"
    items={this.props.fields}
    selectedItems={this.state.selected}
    onChange={(selected) => this.setState({ selected )}
/>

It looks like this could be achieved by adding this line:
this.props.onChange(selectedItems.result.map(id => selectedItems.entities.item[id]));

to the _onChipClose and _selectItem functions.

BukhariMuslim commented 6 years ago

@raynor85 could you please check this and decide to merge this (#4) or not?

raynor85 commented 6 years ago

@BukhariMuslim #4 breaks the emailValidation example. I would love to merge it, but backwards compatibility must be guaranteed. @grailian if you don't mind, can you please add this in your PR? Thanks

raynor85 commented 6 years ago

onChangeSelectedItems props has been added with d61ca89b916979e3a377740afbeb742e377c31f9