【问题标题】:Getting DragHandle error with react-beautiful-dnd使用 react-beautiful-dnd 获取 DragHandle 错误
【发布时间】:2018-07-18 16:21:51
【问题描述】:

我正在使用 react-beautiful-dnd 版本 8.0.5(最新)并尝试呈现可重组的列表,但我不断收到此错误:

Warning: React.createElement: type is invalid -- expected a string (for 
built-in components) or a class/function (for composite components) but 
got: undefined. You likely forgot to export your component from the file 
it's defined in. Check the render method of `DragHandle`.

我从this example 复制了部分代码。我目前使用 react-redux、Formik 的 HOC 和 react-virtualized-select。当我将代码复制到codesandbox example 时,它至少会呈现(我猜是有问题)。有谁有想法吗?如果需要,我可以提供更多代码。

【问题讨论】:

  • 你在项目中使用的是什么反应版本?
  • @Pintouch 15.6.1

标签: reactjs react-redux formik


【解决方案1】:

react-beautiful-dnd V8.0.5 作为 React 16 check their package.json 的对等依赖项

这解释了为什么它在沙箱中渲染 (React 16),而它在您的项目中不起作用 (React 15)。

当你执行npm install时你应该有警告:

您可以将 React 15 更新到 React 16 或降级 react-beautiful-dnd 的版本,找到最后一个适用于 React 15 的版本。

【讨论】:

  • 你是对的。有效。非常感谢!只是为了保存,与 React 15 一起使用的 react-beautiful-dnd 的最后一个版本是 6.0.2
  • 我刚刚遇到了同样的问题并通过了这个解决方案。我发现您还必须升级react-domreact。我目前的两个版本都是16.4.2
猜你喜欢
  • 2019-04-24
  • 2019-03-19
  • 2022-11-24
  • 2023-01-10
  • 2020-05-11
  • 1970-01-01
  • 2022-12-29
  • 1970-01-01
  • 2020-05-05
相关资源
最近更新 更多