react-native-material-design-searchbar
react-native-material-design-searchbar copied to clipboard
onSearchChange proposal
onSearchChange is fired when the text is change and on reset. The problem is that the function is called in 2 different ways, directly by passing the value of TextInput's onChangeText and via _onClose at https://github.com/ananddayalan/react-native-material-design-searchbar/blob/master/SearchBar.js#L77
What do you think if _onClose fires onSearchChange with just an empty string or we add a new event onInputClear / onInputReset ?
I agree that this is a bit counter-intuitive.
To handle the current way of calling onSearchChange, my code looks like this:
<SearchBar
onSearchChange={(query) => {
if(typeof query != 'string')
query = query.nativeEvent.text;
this.props.onChangeSearchQuery(query);
}}
height={lookAndFeel.baseTextInputHeight}
placeholder={'Search ...'}
autoCorrect={false}
padding={lookAndFeel.defaultPadding}
/>
Removing the if statement would be nice. 👍
Looks like this was fixed in https://github.com/ananddayalan/react-native-material-design-searchbar/commit/d9987c18c6a0663a5bcdfbd4b87d204f2f45e1e3
Is that working as you expect?