- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
嗨,我是 React 的新手,遇到了 react-beautiful-dnd 问题。我似乎已经按照文档进行了配置,但仍然面临与可拖动 ID 相关的奇怪问题。
但问题依然存在。需要这方面的专家帮助。
CodeSandBox 链接:Link to react beautiful dnd codesandbox issue code
同时添加代码以便快速浏览:
import "./styles.css";
import { DragDropContext, Draggable, Droppable } from "react-beautiful-dnd";
import { useState } from "react";
export default function App() {
const [list, setList] = useState(generateData());
const st = {
width: "300px",
cursor: "grab",
display: "flex",
gap: "10px",
flexDirection: "column"
};
const onDragEnd = (result) => {
if (result.destination) {
alert("drag successfull");
}
};
return (
<div className="App">
<h4>Test</h4>
<div>
<DragDropContext onDragEnd={onDragEnd}>
<Droppable droppableId="droppable">
{(provided) => (
<div
{...provided.droppableProps}
ref={provided.innerRef}
style={st}
className="work-parent"
>
<WorkList list={list} />
</div>
)}
</Droppable>
</DragDropContext>
</div>
</div>
);
}
function WorkList({ list }) {
return list.map((l, index) => <Work key={l.id} work={l} index={index} />);
}
function Work({ work, index }) {
const st = {
padding: "10px",
width: "100%",
color: "white",
backgroundColor: "purple",
width: "200px",
height: "50px"
};
return (
<Draggable draggableId={work.id} key={work.id} index={index}>
{(provided) => (
<div
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
style={st}
>
{work.title}
</div>
)}
</Draggable>
);
}
function generateData() {
const data = [];
for (let i = 0; i < 10; i++) {
data.push({
title: "Work - " + i,
id: makeid(5)
});
}
return data;
}
function makeid(length) {
var result = "";
var characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
最佳答案
乍一看,您的代码是正确的。您遇到的问题是关于升级 React v18。作为临时解决方案,我建议您删除 <StrictMode>
包装器和您的应用程序将工作。
您可以在此处找到有关此问题的更多信息:https://github.com/atlassian/react-beautiful-dnd/issues/2350
更新:
降级到 React v17 也可能有帮助: https://github.com/atlassian/react-beautiful-dnd/issues/2407
更新 2:
我还没有亲自测试过,但似乎这可能是使用 React v18 并且不删除 <StrictMode>
的解决方法: https://github.com/atlassian/react-beautiful-dnd/issues/2399#issuecomment-1167427762
关于javascript - 无法找到 ID 为 : b7zc6 的可拖动对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72316182/
Glpk 需要使用configure make install 命令构建。所以我使用 zc.recipe.cmmi 配方来构建 glpk 包。它在 bin 目录中生成 glpsol 命令。我需要能够在
我正在尝试在新的 Django 项目中使用 zc.buildout。我真的很喜欢这个工具背后的想法,当然也很感激为这个工具付出的努力。尽管缺少文档,但我感到很惊讶。我列出了我认为是关于扩建或与扩建密切
我对 python egg 版本有疑问。在我的开发机器上,我有 python-ldap 版本 2.3.13,而大学在他们的机器上有版本 2.3.10。两个 python-ldap 库都安装在操作系统级
我想在/Zc:wchar_t 设置为 Yes 的情况下编译 Qt。这是我打算如何编译它: configure -debug-and-release -opensource -platform win3
我刚刚设置了我的项目,但在让 Django 工作时遇到问题。这是我的 buildout.cfg: [buildout] parts = python django develop = . eggs =
最近,由于存在(或不存在)此标志,我遇到了一些链接问题。 /Zc:wchar_t- 我读过 docs ,但他们没有提到尾随减号。但每一次关于它的讨论似乎都包括它。什么意思? 最佳答案 /Zc:wcha
我们的一个网站有一个损坏的关系目录,我不知道如何修复它。 这是我在日志中看到的: 2015-11-20T09:27:43 ERROR Zope.SiteErrorLog 1448018863.240.
我正在尝试让 zc.buildout 从源代码安装 Gunicorn。使用以下配置: [gunicorn] recipe = collective.recipe.distutils url = htt
我是 zc.buildout 的新手,希望开始使用它。我正在研究将 Eggs 配置为零件和模块的概念,并在 cfg 文件中将其开发为develop-eggs。我无法弄清楚应该如何为正在开发的模块配置外
我使用 zc.buildout 来构建我的 python 应用程序环境。我想运行 IPython 笔记本并使用我的自定义包来进一步测试和开发。 [buildout] extends = buildou
我创建了一个自动安装 nginx 的 zc.buildout 配置,带有配置和启动脚本。 一切正常,除了,为了成功运行 nginx,我必须以 sudo 运行它。我在 ubunut 下运行它,只是想知道
我正在尝试在运行 Debian 和 Python 2.7.1 的网络服务器上使用 ZODB 3.10.2。似乎每次我尝试从 2 个不同的进程访问同一个数据库时,我都会遇到一个神秘的异常。我尝试从交互式
我的项目使用 buildout 主要做两件事:自动获取依赖项和创建脚本;并使用 usercrontab 构建配方设置 cron 作业(在部署机器上)。 但是 Python 3 尚不能使用 buildo
我想使用 buildout 进行依赖管理,我听说 distribute 是管理项目安装的新好方法。 但是,简单的入门教程似乎很少见。我见过的最直接的是 Jacob Kaplan-Moss 的 Deve
我使用 zc.buildout 来开发我的项目并下载依赖项(use-site-packages off)。 我想在运行之前将我的项目作为一个包安装到目标系统上。为此,我制作了 setup.py。 我是
我看了this video并尝试使用源代码发布工具。 首先,这是文档中不确定的部分: To create a source release, simply run the buildout-sourc
我一直在我的机器上使用 IPython 而不是默认的 Python 解释器,因为它有更多的特性,而且通常感觉更强大。我想在我的 zc.buildout 项目中将它用作 bin 目录中的解释器,就像此部
我正在尝试使用以下指南为 Django 1.4 项目创建开发环境: http://www.stereoplex.com/blog/a-django-development-environment-wi
我正在尝试使用 zc.buildout 从私有(private) reportlab pypi 服务器安装 python 包。 当我使用他们自己网站上提供的说明进行安装时,安装没有问题。 http:/
我正在尝试安装基于 Plone 的 Plumi 4.5.1。 目标系统是 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64
我是一名优秀的程序员,十分优秀!