当我在TextInput中输入内容时,我会第一次touch 其中一个平面列表项.应该是console.log('item press')
,但不是.只有第二次触碰才让人感到安慰.有人知道原因吗?
这是我的密码.
<TextInput
placeholder='test'
value={this.state.inputText}
onChangeText={(inputText) => this.setState({inputText})}
style={{
marginBottom: 20,
fontSize: 17,
width: 300,
textAlign: 'center''
}}
/>
<FlatList
data={[{key: 'item 1'}, {key: 'item 2'}]}
renderItem={({item}) =>
<TouchableHighlight
onPress={() => console.log('item press')}
underlayColor='#dddddd'
>
<View style={{height: 40}}>
<Text style={{fontSize: 16, textAlign: 'center'}}>{item.key}</Text>
</View>
</TouchableHighlight>
}
/>