我想在外面点击一个组件时隐藏它.像解雇键盘之类的东西.我通过改变状态onPress将我的整个视图包装在ToucheableWithoutFeedback中来完成此操作,但是Toucheables禁用了ScrollView.
你能告诉我一个滚动视图仍然有效的方法吗?
要么
如何处理视图中或组件外部的点击?
我目前的代码是这样的:
<TouchableWithoutFeedback onPress={() =>{this.setState({toggle:false})}}>
<View>
{//content}
</View>
<ScrollView>
{//lists here}
</ScrollView>
{{
if(this.state.toggle){
return
(<View>
{//The view that im hiding when clicking outside it}
</View>)
}
else
return <View/>
</TouchableWithoutFeedback>
Run Code Online (Sandbox Code Playgroud) 如何检测视图外部的水龙头(视图是一个小的宽度和高度为200)。例如,我有一个自定义View(类似于模式),它的可见性由状态控制。但是,当在其外部单击时,由于未完成setState,因此未进行任何更改,我需要捕获用户(除了模式内部)无处不在。在React Native中怎么可能?