Skip to content

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

Open
@rhyek

Description

@rhyek

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions