From 6234f7f72eb46aed7b7ca2bad684883db0618626 Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Tue, 30 Apr 2019 19:08:14 +0200 Subject: [PATCH] React native autocomplete input/add v4 flatlist props (#35102) * fix(react-native-autocomplete-input): add flatListProps introduced in v4 * fix(react-native-autocomplete-input): add keyExtractor prop introduced in v4 * chore(react-native-autocomplete-input): remove unused imports in example --- types/react-native-autocomplete-input/index.d.ts | 13 +++++++++++++ .../react-native-autocomplete-input-tests.tsx | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/types/react-native-autocomplete-input/index.d.ts b/types/react-native-autocomplete-input/index.d.ts index df5ab5e507..eb4bca3986 100644 --- a/types/react-native-autocomplete-input/index.d.ts +++ b/types/react-native-autocomplete-input/index.d.ts @@ -12,6 +12,7 @@ import { StyleProp, TextInputProperties, ViewStyle, + FlatListProps, } from 'react-native'; export interface AutocompleteProps extends TextInputProperties { @@ -33,12 +34,24 @@ export interface AutocompleteProps extends TextInputProperties { */ data: T[]; + /** + * object + * Props to pass on to the underlying FlatList. + */ + flatListProps?: Partial>; + /** * style * These styles will be applied to the container which surrounds the textInput component. */ inputContainerStyle?: StyleProp; + /** + * function + * keyExtractor will be called to get key for each item. It's up to you which string to return as a key. + */ + keyExtractor?(item: T, i: number): string; + /** * style * These styles will be applied to the container which surrounds the result list. diff --git a/types/react-native-autocomplete-input/react-native-autocomplete-input-tests.tsx b/types/react-native-autocomplete-input/react-native-autocomplete-input-tests.tsx index 36dd6b516f..8de641a11a 100644 --- a/types/react-native-autocomplete-input/react-native-autocomplete-input-tests.tsx +++ b/types/react-native-autocomplete-input/react-native-autocomplete-input-tests.tsx @@ -1,10 +1,8 @@ import Autocomplete from 'react-native-autocomplete-input'; import * as React from 'react'; import { - StyleSheet, Text, TouchableOpacity, - View } from 'react-native'; interface Item { query: string; value: string; } @@ -24,6 +22,8 @@ class AutocompleteExample extends React.Component<{}, {query: string}> { return ( {} }} + keyExtractor={item => item.value} onChangeText={text => this.setState({ query: text })} renderItem={({ item }) => ( this.setState({ query: item.query })}>