nodeRef solution for React 19 does not work due to incorrect build output

未关闭
#779 1 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript, react

调研方向

Start with lib/DraggableCore.js at the nodeRef check and compare its behavior with the compiled output shown in the issue. Run or review the linked main.spec.ts tests to reproduce the empty-ref case. Done means the built package preserves the intended nodeRef behavior and the React 19 scenario no longer falls back to findDOMNode.

由索引模型根据 Issue 内容生成。

描述

The recommended solution for the React 19 findDOMNode removal is to provide a DOM element reference via nodeRef. This does not work due to how react-draggable is being built.

The check being done for provided nodeRef here falls back to using ReactDOM.findDOMNode when nodeRef is an empty ref ({ current: null }), which is always the initial value for DOM refs.

The source code appears to be doing the correct thing and should not result in this behavior, but the compiled code changes the behavior:

findDOMNode() {
  var _this$props$nodeRef$c, _this$props;
  return (_this$props$nodeRef$c = (_this$props = this.props) === null || _this$props === void 0 || (_this$props = _this$props.nodeRef) === null || _this$props === void 0 ? void 0 : _this$props.current) !== null && _this$props$nodeRef$c !== void 0 ? _this$props$nodeRef$c : _reactDom.default.findDOMNode(this);
}

I have some tests proving this here.

Image

主要语言
JavaScript
星标
9.3k
派生
1k
平均合并
3 天 8 小时
30 天内合并 PR
4

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

react-grid-layout/react-draggable 的其他 Issue

查看 react-grid-layout/react-draggable 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。