We have a few React elements wrapped up in ReactElementWidget, as does the JupyterLab code base. One of them is particularly heavyweight, which helped surface this issue. Because ReactElementWidget makes no call to ReactDOM.unmountComponentAtNode(), the react elements rendered using this wrapper widget never get fully cleaned up.
(nb. React Dev Tools doesn't seem to like the iframe, if you open the output in a new window then you will be able to inspect the React DOM)
If you have React Dev Tools, you can see the <div>. When you click on the "Hi" text, it disposes itself and cleans the React node up. However, if you uncomment the line unmountComponentAtNode(this.node); (index.tsx:13), then when it gets disposed, the react element hangs around in memory.
I'd expect it would be disposed as part of #dispose(), either in ReactElementWidget or the VDomRenderer. While it's possible for subclassers to do it, it opens up a leaky abstraction if multiple ReactDOM instances are loaded on the page (you need to get the ReactDOM instance that @jupyterlab/apputils is using).
The text was updated successfully, but these errors were encountered: