iOS18+环境下React Native项目启动报TypeError: config.easing非函数
解决iOS18+环境下
config.easing is not a function错误 核心原因
react-native-reanimated 2.5.0版本过旧,未适配iOS18的API变更,导致easing参数的解析逻辑与系统新环境冲突。
具体修复步骤
升级react-native-reanimated到兼容版本
安装2.17.0及以上的稳定版本(该版本修复了iOS18的适配问题):npm install react-native-reanimated@2.17.0 --save # 或使用yarn yarn add react-native-reanimated@2.17.0校验easing参数的使用方式
确保代码中withTiming等动画函数的easing参数传递的是函数类型,而非对象。示例:import { Easing } from 'react-native'; import { withTiming } from 'react-native-reanimated'; const animatedStyle = useAnimatedStyle(() => { return { opacity: withTiming(1, { duration: 500, easing: Easing.inOut(Easing.ease) // 传递函数而非对象 }) }; });清理全链路缓存
- 删除依赖并重装:
rm -rf node_modules && npm install - 清理iOS CocoaPods缓存并重装:
cd ios && pod deintegrate && pod install && cd .. - 重置Metro缓存并重启服务:
npx react-native start --reset-cache - 在Xcode中执行
Product -> Clean Build Folder,重启模拟器/设备。
- 删除依赖并重装:
可选:升级React Native版本
若上述步骤无效,可将React Native升级到0.68.x及以上版本(该版本对iOS18兼容性更好),同时确保reanimated版本与之匹配。
内容的提问来源于stack exchange,提问作者Emanuele Maria
相关产品推荐
相关产品推荐

