I using react-native-searchable-dropdown library , but if user write string with its not in item array I receive white screen. How I can add no result text (or its best option button who create missing option)?
Actually this is work , just i need to add some details , its need to be change the same Searchable dropdown file:
const oldSupport = [
{ key: 'keyboardShouldPersistTaps', val: 'always' },
{ key: 'nestedScrollEnabled', val : false },
{ key: 'style', val : { ...this.props.itemsContainerStyle } },
{ key: 'data', val : this.state.listItems },
{ key: 'keyExtractor', val : (item, index) => index.toString() },
{ key: 'renderItem', val : ({ item, index }) => this.renderItems(item, index) },
{ key: 'ListEmptyComponent', val : () =>this.emptyComponent()}
I added :
{ key: 'ListEmptyComponent', val : () =>this.emptyComponent()}
after that i just add
emptyComponent = () => {
return(
<View>
<Text>Search result not found</Text>
<Button title='Do Something'/>
</View>
);
};
and in function
emptyComponent
you can do whatever you want