You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native使用drawer导航时出现RNGestureHandler参数不匹配报错如何解决

报错原因

该报错由react-native-gesture-handler与@react-navigation/drawer版本不兼容导致,高版本的react-native-gesture-handler调整了attachGestureHandler方法的入参数量,与你当前使用的抽屉导航版本参数要求不匹配。

解决方案

按以下步骤操作即可修复:

  • 第一步:卸载当前安装的react-native-gesture-handler包
    对应命令:
    # npm用户执行
    npm uninstall react-native-gesture-handler
    # yarn用户执行
    yarn remove react-native-gesture-handler
    
  • 第二步:安装经过验证的兼容版本2.9.0
    对应命令:
    # npm用户执行
    npm install react-native-gesture-handler@2.9.0
    # yarn用户执行
    yarn add react-native-gesture-handler@2.9.0
    
  • 第三步:原生端依赖同步
    iOS用户进入项目ios目录执行pod install,安卓用户无需额外操作。
  • 第四步:清空缓存重启项目
    启动 metro 时添加清空缓存参数,避免残留缓存影响:
    npx react-native start --reset-cache
    
额外代码优化建议

你当前登录页的handleCheckAdmin方法存在逻辑问题:遍历admin列表时会对每一条admin记录执行判断,若admin列表有多条数据,会重复调用navigation.replace方法,可修改为如下逻辑:

const handleCheckAdmin = async (userEmail) => {
    try {
        const admins = collection(db, 'admin');
        const adminSnapshot = await getDocs(admins);
        const adminList = adminSnapshot.docs.map(doc => doc.get("adminEmail"));
        // 直接判断当前登录邮箱是否在管理员列表内
        if (adminList.includes(userEmail)) {
            navigation.replace('Root');
        } else {
            navigation.replace('Members');
        }
    } catch (error) {
        console.log(error);
    }
}

内容的提问来源于stack exchange,提问作者H. Sayouf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 20:36:02