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

Abierto
#779 1 comentario 3 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
38/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript, react

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
JavaScript
Estrellas
9.3k
Forks
1k
Merge medio
3 d 8 h
PR fusionados (30 d)
4

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de react-grid-layout/react-draggable

Todos los issues de react-grid-layout/react-draggable

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.