mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
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
This commit is contained in:
committed by
Wesley Wigham
parent
b36fa43748
commit
6234f7f72e
@@ -12,6 +12,7 @@ import {
|
||||
StyleProp,
|
||||
TextInputProperties,
|
||||
ViewStyle,
|
||||
FlatListProps,
|
||||
} from 'react-native';
|
||||
|
||||
export interface AutocompleteProps<T> extends TextInputProperties {
|
||||
@@ -33,12 +34,24 @@ export interface AutocompleteProps<T> extends TextInputProperties {
|
||||
*/
|
||||
data: T[];
|
||||
|
||||
/**
|
||||
* object
|
||||
* Props to pass on to the underlying FlatList.
|
||||
*/
|
||||
flatListProps?: Partial<FlatListProps<T>>;
|
||||
|
||||
/**
|
||||
* style
|
||||
* These styles will be applied to the container which surrounds the textInput component.
|
||||
*/
|
||||
inputContainerStyle?: StyleProp<ViewStyle>;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -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 (<Autocomplete
|
||||
data={data}
|
||||
defaultValue={query}
|
||||
flatListProps={{ onScroll: () => {} }}
|
||||
keyExtractor={item => item.value}
|
||||
onChangeText={text => this.setState({ query: text })}
|
||||
renderItem={({ item }) => (
|
||||
<TouchableOpacity onPress={() => this.setState({ query: item.query })}>
|
||||
|
||||
Reference in New Issue
Block a user