【长期更新】RN+expo 错误解决方案

Warning: Internal React error: Expected static flag was missing. Please notify the React team

复现的代码

import { useEffect, useRef } from 'react'
import React from 'react';

const ModalShop = ({ isVisible, onClose }) => {

    if (!isVisible) return null;

    const handleClose = (e) => {
        if (e.target.id === 'wrapper') { onClose(); }
    }

    const inputRef = useRef(null);
    const spanRef = useRef(null);

    useEffect(() => {
      ...

    }, []);
    

    return (...
}

export default ModalShop;

解决:

 if (!isVisible) return null; // 移动到钩子后面

TypeError: dependencies is not iterable

原文连接:https://github.com/expo/create-react-native-app/issues/931#issuecomment-2353688003

解决:删除C:\Users{user}\AppData\Local\Temp

或者

  • 删除 React Native 项目内的“.expo”文件夹
  • npm cache clean --force来清除全局 npm 缓存
  • npx expo start --clear重新启动服务器
  • npx expo start --tunnel在隧道中重启服务器

打包失败

例如:
在这里插入图片描述

  • Build failed: Gradle build failed with unknown error. See logs for the “Run gradlew” phase for more information.
  • cannot find symbol import expo.core.ExpoModulesPackage

首先执行检查下依赖冲突

npx expo-doctor

如果你使用pnpm, 在.npmrc新增

node-linker=hoisted

我到这里就可以了。
如果还不行
在package.json 新增:
“expo-modules-autolinking”: “*”

参考:https://github.com/expo/eas-cli/issues/2789

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_pengliang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值