【发布时间】:2020-05-27 20:40:29
【问题描述】:
我正在尝试在我的 react-native 项目中实现 react-native-google-places-autocomplete,而 onPress 函数根本不起作用。我已经尝试过 StackOverflow 上的其他解决方案,但它根本不起作用。我还向父组件添加了“keyboardShouldPersistTaps='always'。如果有帮助,我会使用“navigation.navigate("maps")”进入此屏幕。
这里是代码。
class ChangeAddress extends PureComponent<Props> {
render() {
const { navigation } = this.props;
return (
<ScrollView
contentContainerStyle={{ flex: 1 }}
style={styles.modalContainer}
keyboardShouldPersistTaps="always">
<View style={styles.modalHeader}>
<Button onPress={() => navigation.goBack()} style={styles.backButton}>
<Image source={backLogo} />
</Button>
<View style={styles.searchBar}>
<View>
<Text style={styles.pickUpLocation}>Set Pickup Location</Text>
</View>
<GooglePlacesAutocomplete
placeholder="Search"
minLength={2}
autoFocus={false}
listViewDisplayed={false}
renderDescription={(row) => row.description}
fetchDetails={true}
onPress={(data, details = null) => {
console.log('HIIIIIIIIIIIIIIIIII', data, details);
}}
query={{
key: 'API',
language: 'en',
}}
styles={{
textInputContainer: {
backgroundColor: 'rgba(0,0,0,0)',
borderTopWidth: 0,
borderBottomWidth: 0,
width: '90%',
},
textInput: {
marginLeft: 0,
marginRight: 0,
height: 40,
color: '#5d5d5d',
fontSize: 14,
borderWidth: 1,
borderColor: '#778899',
},
predefinedPlacesDescription: {
color: '#1faadb',
},
description: {
fontWeight: 'bold',
borderTopWidth: 0,
borderBottomWidth: 0,
opacity: 0.9,
},
listView: {
color: 'black',
position: 'absolute',
top: 70,
left: -40,
width: dimens.width,
elevation: 1,
},
}}
/>
</View>
</View>
</ScrollView>
);
}
}
我错过了什么?提前致谢。
【问题讨论】:
标签: react-native