Skip to content

Remove findDOMNode#399

Open
ethanshealey wants to merge 1 commit intoreact95-io:masterfrom
ethanshealey:master
Open

Remove findDOMNode#399
ethanshealey wants to merge 1 commit intoreact95-io:masterfrom
ethanshealey:master

Conversation

@ethanshealey
Copy link
Copy Markdown

Remove findDOMNode (React 19 compatibility)

ReactDOM.findDOMNode was removed in React 19. The useIsFocusVisible hook
was calling it to resolve the DOM node from a ref callback, which breaks
entirely in React 19.

The fix is straightforward — ref callbacks already receive the DOM node as
instance, so findDOMNode was never doing anything useful here. Dropping
it and using instance directly is equivalent behavior.

Fixes the following crash when running React 19:
TypeError: reactDom.findDOMNode is not a function

@ethanshealey
Copy link
Copy Markdown
Author

Hello @arturbien! This small fix is critical for those on React 19+ using React95

For anyone else running into this issue, you can create a patch as a temporary fix:

diff --git a/node_modules/react95/dist/common/hooks/useIsFocusVisible.js b/node_modules/react95/dist/common/hooks/useIsFocusVisible.js
index 6a14447..cbe8726 100644
--- a/node_modules/react95/dist/common/hooks/useIsFocusVisible.js
+++ b/node_modules/react95/dist/common/hooks/useIsFocusVisible.js
@@ -3,7 +3,6 @@
 Object.defineProperty(exports, '__esModule', { value: true });
 
 var React = require('react');
-var reactDom = require('react-dom');
 
 let hadKeyboardEvent = true;
 let hadFocusVisibleRecently = false;
@@ -78,7 +77,7 @@ function handleBlurVisible() {
 }
 function useIsFocusVisible() {
   const ref = React.useCallback((instance) => {
-    const node = reactDom.findDOMNode(instance);
+    const node = instance;
     if (node != null) {
       prepare(node.ownerDocument);
     }
diff --git a/node_modules/react95/dist/common/hooks/useIsFocusVisible.mjs b/node_modules/react95/dist/common/hooks/useIsFocusVisible.mjs
index afef844..5160830 100644
--- a/node_modules/react95/dist/common/hooks/useIsFocusVisible.mjs
+++ b/node_modules/react95/dist/common/hooks/useIsFocusVisible.mjs
@@ -1,5 +1,4 @@
 import { useCallback } from 'react';
-import { findDOMNode } from 'react-dom';
 
 let hadKeyboardEvent = true;
 let hadFocusVisibleRecently = false;
@@ -74,7 +73,7 @@ function handleBlurVisible() {
 }
 function useIsFocusVisible() {
   const ref = useCallback((instance) => {
-    const node = findDOMNode(instance);
+    const node = instance;
     if (node != null) {
       prepare(node.ownerDocument);
     }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant