i spent two days on this problem , the problem is :
when i placed a TextInput inside a Flatlist , the behavior of the TextInput Changed , the Keyboard lose focus after every character writed.
Version React-native : 0.63.2 react : 16.13.1, react-dom : 16.13.1, expo : ~42.0.1,
Steps to reproduce
- i reated a State Variable called ==> [inputSearch, setInputSearch]
- i wrote a textinput inside the ListHeaderComponent of Flatlist
---> The problem is : After every Character pressed in Keyboard the Keyboard Hide
State declaration :
const [inputSearch, setInputSearch] = useState(null);
TextInput is inside Flatlist :
<View style={styles.container}>
<StatusBar
backgroundColor="#11131B"
barStyle="light-content"
/>
<View style={{width: '100%', flex: 1 , backgroundColor: 'white', marginTop: 5}}>
<FlatList
contentContainerStyle={{alignItems: 'center',paddingHorizontal: 20}}
keyExtractor={(item) => (Object.keys(item).length === 0) ? "" : item.id.toString()}
width= {width}
numColumns={2}
ListHeaderComponent={() =>
<View style={{flexDirection:'column',justifyContent:'space-between'}}>
<Text style={{color:Colors.dark1, fontSize:14, marginBottom: 5}}>Search :</Text>
<TextInput style={styles.input} value={inputSearch} onChangeText={setInputSearch} placeholder="Username"/>
</View>
}
data={SIMPLE_DATA}
renderItem={renderItemRow}
>
</FlatList>
</View>
<View>