我正在使用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时,它至少会渲染(我猜是出了问题)。有人有什么主意吗?如果需要,我可以提供更多代码。
最佳答案
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 的版本。
关于reactjs - 使用react-beautiful-dnd获取DragHandle错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51406803/