fix: point React 19 users at nodeRef when it is missing - #826
Juice-de-Orange wants to merge 1 commit into
Conversation
React 19 has no ReactDOM.findDOMNode, so <DraggableCore> can only find its node through nodeRef. The hint for that went through `log`, which is a no-op unless DRAGGABLE_DEBUG is set, and the first drag then threw "<DraggableCore> not mounted on DragStart!" without mentioning nodeRef. Warn once per instance on mount instead, link the README section (the old #noderef anchor does not exist), and say in the drag start error that no nodeRef was provided. React 18 and earlier still use findDOMNode and are unchanged.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughDraggableCore now checks whether ReactDOM.findDOMNode is available. It warns once per instance when neither that function nor nodeRef is available, and reports a React 19-specific error if a drag starts without a usable node. Tests cover warning and error cases. ChangesDOM lookup compatibility
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue is identified in the React 19 missing-node handling; the PR is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
lib/DraggableCore.tsxESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. test/Draggable.test.jsxESLint skipped: the matched ESLint configuration already failed (missing-dependency). test/DraggableCore.test.jsxESLint skipped: the matched ESLint configuration already failed (missing-dependency). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #771, following the agent brief.
On React 19 without
nodeRef,DraggableCore#findDOMNode()sent its hint throughlog, which is a no-op unlessDRAGGABLE_DEBUGis set, so the first visible sign was<DraggableCore> not mounted on DragStart!on mousedown. Now each instance warns once on mount withconsole.warn, namingnodeRefand linking the README section (#using-noderef; the old#noderefanchor doesn't exist). When the drag start finds no node becausenodeRefis missing andReactDOM.findDOMNodeis gone, the error says so and links the same section; every other case keeps the old message. React 18 still takes thefindDOMNodepath, so nothing changes there.New unit tests cover the single warning (also under StrictMode), the drag start error naming
nodeRef, the old error for anodeRefthat is passed but not attached, and no warning withnodeRef; the first three fail without the change.make lint,make buildandmake test-allpass on Node 22 (209 unit, 23 browser tests),yarn testalso on Node 24. With the built UMD bundle in headless Chrome, React 18.3.1 logs and drags the same as before, and React 19.3.0 warns once, also under StrictMode.Summary by CodeRabbit
nodeRefis needed.nodeRefavoids the compatibility warning.