Description
Do you want to request a feature or report a bug?
Report a bug
What is the current behavior?
React components with <textarea autoFocus> seem to leak DOM nodes after being unmounted, retaining their entire DOM tree.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
There's a JS Fiddle here:
https://jsfiddle.net/afarnsworth/sw2td7xp/2/
To test, open up the Chrome Performance Monitor, and check and uncheck the "Show stuff" check box. The number of DOM Nodes will climb. Clicking garbage collect will not seem to reclaim any.
You can click "run" in jsfiddle to release the old nodes. Uncheck the "Enable autofocus" box, and repeat the experiment (click "Show stuff" a lot). This time the DOM nodes seem to get reclaimed.
A heap snapshot shows some detached dom trees referenced in React DOM internals
What is the expected behavior?
DOM nodes aren't retained after being unmounted.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 16.3, Google Chrome on Windows.
Don't know if this issue is new or not, our application may have always been affected by this.