<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mike</title>
    <description>The latest articles on DEV Community by Mike (@mikex95).</description>
    <link>https://dev.to/mikex95</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1753622%2F2f7705ba-ac84-40ae-899a-e30b998a4d37.jpeg</url>
      <title>DEV Community: Mike</title>
      <link>https://dev.to/mikex95</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mikex95"/>
    <language>en</language>
    <item>
      <title>Help Needed: Persistent "removeChild" Error with Google Translate on React 18.2.0.</title>
      <dc:creator>Mike</dc:creator>
      <pubDate>Tue, 09 Jul 2024 12:14:32 +0000</pubDate>
      <link>https://dev.to/mikex95/help-needed-persistent-removechild-error-with-google-translate-on-react-1820-3ogn</link>
      <guid>https://dev.to/mikex95/help-needed-persistent-removechild-error-with-google-translate-on-react-1820-3ogn</guid>
      <description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;I'm reaching out for help with a persistent issue we've been experiencing in our React application whenever users translate the page using Google Translate.&lt;/p&gt;

&lt;p&gt;We have the following error message:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This error seems to occur consistently and is proving difficult to resolve. We've already investigated various resources, including this &lt;a href="https://martijnhols.nl/gists/everything-about-google-translate-crashing-react" rel="noopener noreferrer"&gt;https://martijnhols.nl/gists/everything-about-google-translate-crashing-react&lt;/a&gt; on Google Translate issues with React.&lt;br&gt;
Despite these efforts, the problem persists.&lt;/p&gt;

&lt;p&gt;Example Issue in Code&lt;br&gt;
We've already tried to address this issue by wrapping strings in spans or fragments using both the ternary and "And (&amp;amp;&amp;amp;)" operators in our React components. However, we don't believe this fully solves all our problems.&lt;/p&gt;

&lt;p&gt;Here's an example how we tried to fix this issue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JSX:
{checked &amp;amp;&amp;amp; &amp;lt;span&amp;gt;checked&amp;lt;/span&amp;gt;}

or

JSX:
{checked ? &amp;lt;&amp;gt;checked&amp;lt;/&amp;gt; : &amp;lt;&amp;gt;not checked&amp;lt;/&amp;gt;}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sentry Issue Trace&lt;/strong&gt;&lt;br&gt;
Additionally, here is a snippet from our Sentry logs that shows where the error is being thrown in react-dom.production.min.js:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{snip} c=c.stateNode,8===a.nodeType?a.parentNode.removeChild(c):a.removeChild(c)):X.removeChild(c.stateNode));break;case 18:null!==X&amp;amp;&amp;amp;(Xj?(a=X,c=c. {snip}&lt;/code&gt;&lt;br&gt;
Logger Output:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
  "arguments": [&lt;br&gt;
    {&lt;br&gt;
      "message": "Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.",&lt;br&gt;
      "name": "NotFoundError",&lt;br&gt;
      "stack": "Error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.&lt;br&gt;
        at Ay (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:26323)&lt;br&gt;
        at Qs (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:26029)&lt;br&gt;
        at Ay (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:27105)&lt;br&gt;
        at da (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:27642)&lt;br&gt;
        at My (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:29288)&lt;br&gt;
        at da (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:27797)&lt;br&gt;
        at My (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:30975)&lt;br&gt;
        at da (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:27797)&lt;br&gt;
        at My (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:27910)&lt;br&gt;
        at da (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:27797)&lt;br&gt;
        at My (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:29137)&lt;br&gt;
        at U2 (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:41368)&lt;br&gt;
        at Mc (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:40773)&lt;br&gt;
        at ph (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:41:36158)&lt;br&gt;
        at j (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:26:1672)&lt;br&gt;
        at MessagePort.Ee (https://testTest123.net/assets/chunks/chunk-wXiuE3H-.js:26:2049)"&lt;br&gt;
    }&lt;br&gt;
  ],&lt;br&gt;
  "logger": "console"&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Has anyone else encountered this issue, especially in applications using Google Translate? Are there known workarounds or fixes that can be implemented to prevent this error?&lt;/p&gt;

&lt;p&gt;Any insights or suggestions on how to tackle this problem would be greatly appreciated. We are looking for a more robust solution to ensure our application remains stable and user-friendly even when translated.&lt;/p&gt;

&lt;p&gt;Reminder: "noTranslation" is not an option for us, we need to find a proper way to work around this issue.&lt;/p&gt;

&lt;p&gt;Thank you in advance for your help!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
