我有一个使用 reanimated-bottom-sheet
包创建的底部表,如下所示
<BottomSheet
ref={this.bottomSheetRef}
snapPoints={[0, 270]}
renderContent={() => <TextEditor/>}
renderHeader={() => <View style={{ height: 70, backgroundColor: 'red' }}><Text>HEADER</Text></View>}
enabledBottomClamp={true}
callbackNode={fall}
enabledInnerScrolling={false}
/>
我可以使用 this.bottomSheetRef.current.snapTo(1)
/this.bottomSheetRef.current.snapTo(0)
但是当在正文/标题中向下滑动时,工作表不会关闭。
最佳答案
您可能错误地安装了库 react-native-gesture-handler。 更新您的 MainActivity.java 文件(或您创建 ReactActivityDelegate 实例的任何位置),以便它覆盖负责创建 ReactRootView 实例的方法,然后使用此库提供的 Root View 包装器。不要忘记导入 ReactActivityDelegate、ReactRootView 和 RNGestureHandlerEnabledRootView:
import com.facebook.react.ReactActivity;
+ import com.facebook.react.ReactActivityDelegate;
+ import com.facebook.react.ReactRootView;
+ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
public class MainActivity extends ReactActivity {
@Override
protected String getMainComponentName() {
return "Example";
}
+ @Override
+ protected ReactActivityDelegate createReactActivityDelegate() {
+ return new ReactActivityDelegate(this, getMainComponentName()) {
+ @Override
+ protected ReactRootView createRootView() {
+ return new RNGestureHandlerEnabledRootView(MainActivity.this);
+ }
+ };
+ }
}
关于React-Native - reanimated-bottom-sheet - 无法向上/向下拖动底部工作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58689320/