-
Notifications
You must be signed in to change notification settings - Fork 47.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"NotFoundError: Failed to execute 'removeChild' on 'Node'" when using React.Fragment <></> with Chrome extension which does not modify the DOM tree below the root div of the React app #17256
Comments
@tonix-tuft is there any way you can reproduce the issue without the TransOver extension? It seems likely that the extension is doing something other than just appending an element to the body. Maybe try using Chrome's debugger to see what element it is failing on? |
@aweary I could try patching I think this issue is related to: https://stackoverflow.com/questions/21926083/failed-to-execute-removechild-on-node |
I have added the following patched
At the time when React throws the error (hover on the Could it be that TransOver replaces the original "Loading..." text node with a different one and React does not know that? But then, if TransOver does this, I would expect to see What could you advise me to do in order to replicate this issue without using TransOver? I do not know what kind of DOM mutation it performs... |
@aweary I was able to reproduce this in this codesandbox: |
I can reproduce your error too. |
Ah, yeah this is actually a different issue. Transover does not mutate the dom like google translate does. |
Don't you think they are related? |
While I'm not sure, this might be the same problem as happens with Chromoji and scrolling mastodon feeds. https://github.com/smeeckaert/chromoji/issues/15
|
Having the same issue here. Some translation extension is messing up fragment components |
Is the workarround here then not to put text directly in a fragment, but rather wrap it with a proper dom element? |
I've been seeing these errors on regex101.com quite a lot, around 20,000 times in the past 14 days. After some googling I found this, and it seems like this might be the root cause. What are the mitigations? Is there any viable workaround? |
Hey everyone, |
I removed the chrome translation extension, didn't work. |
For i18next with TransOver there is now a workaround available here. I still hope that this is getting fixed legitimately... |
I'm using i18next and in my tests with TransOver, this workaround didn't work. My page crashes both using
Only one solution that worked for me (stop to crash) is inserting this piece of code before my page loads:
|
Related to #11538 |
Para mim funcionou, e eu estou utilizando o EDGE que estava com este bug. |
It happened in my project by having |
这问题太明显,在代码中只要使用<></>,在发生热更新的时候就会触发这个问题,这意味着,使用<></>(React.Fragment)就没办法使用react18。 if you want duplicate bug, you can use this project: https://gitee.com/shuzipai/meikeyun-create-app |
TransOver has been fixed to have |
If you want to allow your users to still translate the page (which is recommended if you have global visitors). I recommend using the workaround in the following comment: #11538 (comment)
|
Now there are several ways to bypass this problem, but I would like to ask if there is an estimated repair time for react itself @aweary |
It seemed like a possible problem with extensions that manipulate the DOM, not just translation extensions. Essentially, I thought the rendering engine manipulated the DOM that the application developer expected and the extension manipulated the DOM cloned from it and presented it to the end user. |
Hi Team, |
@pradella, Did you fix this error ? |
I had this same error using react-native-web, and using Google Translate Page. The specific component that was giving me problems was this one. function Dots() {
const [dots, setDots] = useState('...')
useEffect(() => {
const interval = setTimeout(() => {
setDots(dots.length === 3 ? '' : dots + '.')
}, 500)
return () => {
clearInterval(interval)
}
}, [dots])
return dots
} The way I fixed is by returning a wrapper component instead of pure string. ...
return <DotsContainer>{dots}</DotsContainer>
}
const DotsContainer = styled.Text`` |
|
|
ok |
const MovieApp = () => { // <======================= Uses a
div {isLoading ? ( "Loading..." ) : ( ... |
same here |
This has already been discussed before (#14740), but there wasn't a reproducing example for this kind of issue and I think that my use case is also a bit different.
Do you want to request a feature or report a bug?
I believe this can be considered a bug.
What is the current behavior?
In order to reproduce this issue using Chrome, you will need to install the following Chrome extension called TransOver:
https://chrome.google.com/webstore/detail/transover/aggiiclaiamajehmlfpkjmlbadmkledi?hl=en
I use it to translate text on hover.
The only thing that this extension does is appending a tooltip with the translated text to the
body
HTML element when you hover an element with text (it doesn't seem it appends stuff below the React's rootdiv
element).I have created two code sandboxes to show you better and explain the problem.
It is a minimal example of a movie app like the one Dan showed at JSConf 2018 in Iceland, though not as beautiful as his and without all that cool Suspense stuff, but at least it uses hooks :) .
https://codesandbox.io/s/heuristic-lake-exxvu
https://codesandbox.io/s/magical-grass-016kc
The two code sandboxes are essentially identical, the only difference is that the first one (
heuristic-lake-exxvu
) uses adiv
element forMovieApp
, whereas the second (magical-grass-016kc
) uses aReact.Fragment
(<></>
) component:heuristic-lake-exxvu
'sMovieApp
:magical-grass-016kc
'sMovieApp
:Now, if you open
heuristic-lake-exxvu
and click on theShow movie info
button of any movie in the list, you will see theLoading...
text before the promise with the data of the movie resolves, and theMovie
component is rendered.Before the promise resolves, try hovering on the
Loading...
text with theTransOver
extension enabled, you should see:The world makes sense here, no errors, no warnings, everything works.
Now try to do the same thing on
magical-grass-016kc
, as soon as you hoverLoading...
, you will see theNotFoundError: Failed to execute 'removeChild' on 'Node'
error logged in the browser's console:Here is a streamable video showing this same error:
https://streamable.com/4gxua
What is the expected behavior?
In
heuristic-lake-exxvu
(uses adiv
instead of React fragment), everything worked.The TransOver extension appends to
body
and does not modify the React's rootdiv
neither does it append stuff below it, so I would expect the code in the React fragment example (magical-grass-016kc
) to behave the same and work as inheuristic-lake-exxvu
.Chrome is plenty of useful extensions like this one and they should not really interfere with React, I think that users using React applications may also install other extensions which modify the DOM which they find useful.
If an extension appends to body like TransOver does, I wouldn't expect React to have problems with it and cause undesirable effects and application errors like this one.
This is my opinion, I would be very glad to hear what you think about it, and if you think I have spotted a bug of React fragments (I think it's a bug because, again, it works when using a
div
inheuristic-lake-exxvu
).Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Browser: Chrome
React v16.11.0
React DOM v16.11.0
The text was updated successfully, but these errors were encountered: