React-Native - reanimated-bottom-sheet - 无法向上/向下拖动底部工作表

标签 react-native react-native-reanimated

我有一个使用 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/

相关文章:

android - react-native react-navigation-drawer 在 App 启动时默认保持打开状态

react-native - 使用 Vscode : TypeError: global. performance.now 调试具有 React Native Reanimated 的 React Native 应用程序不是函数

javascript - React Native AsyncStorage 第一次尝试时无法获取

android - 任务 ':app:compileDebugJavaWithJavac' : 执行失败

javascript - 未找到 Travis CI Jest Preset react-native

javascript - 仅在 TextInput 焦点/模糊上运行 Reanimated 动画

react-native-reanimated 模块导致 Android 应用程序在启动时崩溃

react-native - 如何调试react-native-reanimated 2?

javascript - PanGestureHandler 预期 `onGestureHandlerEvent` 监听器是一个函数

reactjs - react native TabNavigator 不显示