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

集成stream-chat-react-native遇_reactNativeReanimated.useSharedValue错误

解决stream-chat-react-native集成中useSharedValue不存在的错误

错误原因

你当前使用的react-native-reanimated@1.13.4属于1.x版本,而stream-chat-react-native@5.15.1依赖Reanimated 2.x版本新增的useSharedValue钩子,二者版本不匹配导致了这个类型错误。

解决方案

步骤1:升级react-native-reanimated到兼容的2.x版本

针对你的React Native 0.62.3,推荐安装适配的2.x版本(如2.2.4,与RN0.62.x兼容性较好):

npm install react-native-reanimated@2.2.4 --save
# 或使用yarn
yarn add react-native-reanimated@2.2.4

步骤2:配置Reanimated 2.x的babel插件

在项目根目录的babel.config.js中,添加Reanimated插件到配置数组:

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: ['react-native-reanimated/plugin'],
};

步骤3:清理缓存并重建项目

# 清除npm/yarn缓存
npm cache clean --force
# 或
yarn cache clean

# 重置Metro缓存
npx react-native start --reset-cache

# iOS项目重新安装依赖并构建
cd ios && pod install && cd ..
npx react-native run-ios

# Android项目直接重新构建
npx react-native run-android

额外提示

如果升级后出现其他兼容性问题,可核对stream-chat-react-native官方文档的依赖要求,确保react-native-gesture-handler等相关依赖也处于兼容版本。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 23:04:57