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

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) // 传递函数而非对象
        })
      };
    });
    
  • 清理全链路缓存

    1. 删除依赖并重装:
      rm -rf node_modules && npm install
      
    2. 清理iOS CocoaPods缓存并重装:
      cd ios && pod deintegrate && pod install && cd ..
      
    3. 重置Metro缓存并重启服务:
      npx react-native start --reset-cache
      
    4. 在Xcode中执行Product -> Clean Build Folder,重启模拟器/设备。
  • 可选:升级React Native版本
    若上述步骤无效,可将React Native升级到0.68.x及以上版本(该版本对iOS18兼容性更好),同时确保reanimated版本与之匹配。

内容的提问来源于stack exchange,提问作者Emanuele Maria

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 04:17:37