@gorhom/react-native-bottom-sheet无法在Android上运行

lb3vh1jj  于 2022-11-17  发布在  React
关注(0)|答案(2)|浏览(165)

我一直在使用这个库为我的react原生应用创建底部表单模态,但它似乎在Android上不起作用,但在iOS上可以。我使用了文档中建议的相同背景组件和句柄组件,所有内容都包含在提供者中,SafeAreaView my package.json包括

"@gorhom/bottom-sheet": "^3.6.5", 
"react-native-reanimated": "^2.0.0",

代码的结构如下:

<BottomSheetModal ref={reference_settings}
                            index      = {1}
                            enableOverDrag={true}
                            onChange   = {(index) => { if(index === 0) { reference_settings.current.dismiss(); } }}
                            snapPoints = {[-1, '50%', '70%']}
                            backdropComponent={Backdrop}
                            handleComponent  ={(props) => (<Belt {...props} />)}
                            style            ={styles.sheet}
                        >
                        <BottomSheetView style={[styles.content]}>
                            <View style={{ width, height: '100%', overflow: 'hidden', backgroundColor: scheme === 'dark' ? '#000' : '#FFF', paddingHorizontal: 10 }}>
                              // the functions inside
                            </View>
                       </BottomSheetView>
</BottomSheetModal>

我使用了正确的配置为Babel的react-native-reanimated包括插件,但它显示出来,然后我不能拖动关闭。

igetnqfo

igetnqfo1#

我知道现在回答你的问题有点晚了,但是我想为其他人补充一下。假设你已经安装了react-native-gesture-handler,你也应该在MainActivity.java中添加一些代码行。

9gm1akwq

9gm1akwq2#

不要忘记在index.js文件中像这样 Package 根应用程序组件
将import语句放在index.js的顶部

import { gestureHandlerRootHOC } from 'react-native-gesture-handler';
import {AppRegistry} from 'react-native';

AppRegistry.registerComponent(appName, () => gestureHandlerRootHOC(App));

更多详细信息

相关问题