Skip to content

findDOMNode is removed in React 19, causing runtime error #579

@ddadaal

Description

@ddadaal

Gitalk 版本

1.8.0

报错信息?

React 19 removed findDOMNode, causing the component no longer rendering.

image

Workaround

A quick workaround is to hot patch the source code, replacing the line calling findDOMNode to just returning null. It seems this only disables animation, but the overall experience still works.

diff --git a/dist/gitalk-component.js b/dist/gitalk-component.js
index a6fa0dc503f89070c6f5c4edeb367f8f9f610028..a02e08e0e11e93a2b2c7b0e165bc41d7d6a541b4 100644
--- a/dist/gitalk-component.js
+++ b/dist/gitalk-component.js
@@ -13473,7 +13473,8 @@ var getNativeNode = exports.getNativeNode = function getNativeNode(element) {
   // While ReactDOM's `findDOMNode` is discouraged, it's the only
   // publicly-exposed way to find the underlying DOM node for
   // composite components.
-  var foundNode = (0, _reactDom.findDOMNode)(element);
+  // var foundNode = (0, _reactDom.findDOMNode)(element);
+  var foundNode = null;
 
   if (!(foundNode instanceof HTMLElement)) {
     // Text nodes are not supported

Possible solution

It seems findDOMNode is only used in animation and is still the only way to do animation, so an option to disable the flip move animation might be able to help. Disabling animation can remove the call to findDOMNode in the runtime.

浏览器版本?

Not matter.

复现步骤?

Upgrade React to 19

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