升级Expo 47后React Native Reanimated报错:configureProps未定义
解决Reanimated
configureProps 未定义的报错 核心原因
react-native-skeleton-content依赖的旧版Reanimated(2.1.0)使用了configureProps方法,但Reanimated 2.3.0+已移除该API,而Expo 47内置的Reanimated版本及你安装的2.13.0均属于移除该API的版本范围,导致依赖库调用了不存在的方法。
可行解决方案
- 替换依赖库:放弃react-native-skeleton-content,改用兼容Reanimated 2.3+的骨架屏库,比如
react-native-skeleton-content-nonexpo或@react-native-material/skeleton这类维护更活跃的库。 - 手动patch依赖库:修改react-native-skeleton-content源码移除
configureProps调用,再用补丁工具固化修改:- 找到
node_modules/react-native-skeleton-content/lib/SkeletonContent.js(或对应源码文件) - 删除调用
Reanimated.configureProps的代码块 - 运行
npx patch-package react-native-skeleton-content生成补丁,确保后续安装依赖时自动应用修改
- 找到
- 锁定Reanimated兼容版本:Expo 47对应兼容的Reanimated版本是2.12.0,尝试降级并锁定依赖:
同时在package.json中配置版本锁定(npm用overrides,yarn用resolutions):npm install react-native-reanimated@2.12.0 # 或 yarn add react-native-reanimated@2.12.0// npm "overrides": { "react-native-skeleton-content": { "react-native-reanimated": "2.12.0" } }
之后删除node_modules和lock文件,重新安装依赖并重启Expo开发服务器。// yarn "resolutions": { "react-native-reanimated": "2.12.0" } - 升级依赖库到兼容版本:检查react-native-skeleton-content是否有适配Reanimated API变更的新版本,若有直接升级:
npm update react-native-skeleton-content # 或 yarn upgrade react-native-skeleton-content
内容的提问来源于stack exchange,提问作者LambentLight
相关产品推荐
相关产品推荐

