@@ -26,7 +26,7 @@ function defaultKeyExtractor(_: unknown, index: number): string {
2626 return `key-${ index } ` ;
2727}
2828
29- function defaultRenderItems < Item > ( { item } : ListRenderItemInfo < Item > ) : React . ReactElement {
29+ function defaultRenderItem < Item > ( { item } : ListRenderItemInfo < Item > ) : React . ReactElement {
3030 return < Text > { String ( item ) } </ Text > ;
3131}
3232
@@ -43,46 +43,48 @@ export const AutocompleteInput = React.forwardRef(function AutocompleteInputComp
4343 onShowResults,
4444 onStartShouldSetResponderCapture = ( ) => false ,
4545 renderResultList : ResultList = FlatList ,
46- renderTextInput : AutoCompleteTextInput = TextInput ,
46+ renderTextInput : AutocompleteTextInput = TextInput ,
4747 flatListProps,
4848 style,
4949 ...textInputProps
5050 } = props ;
5151
52- function renderResultList ( ) : React . ReactElement {
53- const listProps : FlatListProps < Item > = {
52+ function ResultListWrapper ( ) : React . ReactElement {
53+ const resultListProps : FlatListProps < Item > = {
5454 data,
55- renderItem : defaultRenderItems ,
55+ renderItem : defaultRenderItem ,
5656 keyExtractor : defaultKeyExtractor ,
5757 ...flatListProps ,
5858 style : [ styles . list , flatListProps ?. style ] ,
5959 } ;
6060
61- return < ResultList { ...listProps } /> ;
61+ return < ResultList { ...resultListProps } /> ;
6262 }
6363
64- function renderTextInput ( ) : React . ReactElement {
65- const renderProps = {
64+ function TextInputWrapper ( ) : React . ReactElement {
65+ const autocompleteTextInputProps = {
6666 ...textInputProps ,
6767 style : [ styles . input , style ] ,
6868 ref,
6969 } ;
7070
71- return < AutoCompleteTextInput { ...renderProps } /> ;
71+ return < AutocompleteTextInput { ...autocompleteTextInputProps } /> ;
7272 }
7373
7474 const showResults = data . length > 0 ;
7575 onShowResults ?.( showResults ) ;
7676
7777 return (
7878 < View style = { [ styles . container , containerStyle ] } >
79- < View style = { [ styles . inputContainer , inputContainerStyle ] } > { renderTextInput ( ) } </ View >
79+ < View style = { [ styles . inputContainer , inputContainerStyle ] } >
80+ < TextInputWrapper />
81+ </ View >
8082 { ! hideResults && (
8183 < View
8284 style = { listContainerStyle }
8385 onStartShouldSetResponderCapture = { onStartShouldSetResponderCapture }
8486 >
85- { showResults && renderResultList ( ) }
87+ { showResults && < ResultListWrapper /> }
8688 </ View >
8789 ) }
8890 </ View >
0 commit comments