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

react-native-draggable-flatlist遇_isReanimatedSharedValue为null错误求助

解决react-native-draggable-flatlist报错:cannot read property '_isReanimatedSharedValue' of null

以下是针对该报错的几种排查和解决方法:

1. 确认Reanimated 3.x的配置是否完整

Reanimated v3需要额外的babel配置,检查你的babel.config.js是否添加了对应的插件,且该插件必须放在数组最后:

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    // 其他插件
    'react-native-reanimated/plugin', // 必须放在最后
  ],
};

配置完成后,必须重启Metro服务器并清除缓存:

npx react-native start --reset-cache

2. 调整版本兼容

react-native-draggable-flatlist v4可能尚未完全适配Reanimated 3.0,可尝试降级Reanimated到2.x稳定版本:

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

安装完成后同样需要重置Metro缓存。

3. 确保GestureHandlerRootView包裹根组件

将GestureHandlerRootView移至应用的根组件层级,而非仅在当前组件内使用。示例:

// App.tsx
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import DragAndDrop from './DragAndDrop';

export default function App() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <DragAndDrop />
    </GestureHandlerRootView>
  );
}

当前组件内的GestureHandlerRootView可以移除,避免重复包裹。

4. 检查data数组的有效性

确保mySteps数组中的每个item都包含有效的id和name字段,不存在null或undefined的元素,避免组件渲染时出现异常。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.29 19:20:44