[英]React-native: how to use an horizontal scroll view nested inside a native-base Tab component?
我正在使用基于本机的Tabs
,我想在其中一个选项卡中使用水平ScrollView
。
我的代码如下所示:
<Tabs>
<Tab
<MyComponent/>
</Tab>
<Tab
<MyComponent/>
</Tab>
</Tabs>
但是孩子的卷轴不起作用。
我设法使它在孩子滚动时锁定父选项卡。
有一个小吃展示如何在这里
以下是相关代码:
<Tabs locked={this.state.isLocked}>
<Tab
<MyComponent lockTab={this.lockTab}/>
</Tab>
<Tab
<MyComponent/>
</Tab>
</Tabs>
在MyComponent
内部:
handleInnerPressIn = () => this.props.lockTab(true);
handleInnerPressOut = () => this.props.lockTab(false);
<ScrollView nestedScrollEnable={true} horizontal={true}>
<TouchableWithoutFeedback
onPressIn={this.handleInnerPressIn}
onPressOut={this.handleInnerPressOut}>
</TouchableWithoutFeedback>
</SrollView>
需要注意的一件重要事情是,它仅在TouchableWithoutFeedback
位于(而不是包装) ScrollView
时才有效
关注此评论部分: https://github.com/facebook/react-native/issues/21436
最后锁定滚动视图没有像其他人建议的那样工作,我从 react-native-gesture-handler 导入了嵌套的水平滚动视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.