You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: do not let the React dialogs dispose on close
To workaround the React-based widget lifecycle issue:
eclipse-theia/theia#12093.
The dialog constructor is called once, hence the default `toDispose`
listener will execute only once per app lifecycle. The default dialog
close behavior (from Theia) will dispose the widget. On dialog reopen,
the constructor won't be called again, as the dialog is injected as
a singleton, but the React component has been unmounted on dialog
dispose. Hence, they will be recreated. The `componentDidMount`
method will be called, but the `componentWillUnmount` is not called
anymore. The dialog is already disposed. It leads to a resource leak.
Signed-off-by: Akos Kitta <[email protected]>
// This is tricky to bypass the default Theia code.
30
-
// Otherwise, there is a warning when opening the dialog for the second time.
31
-
// You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before. Instead, call root.render() on the existing root instead if you want to update it.
32
-
constdisposables=newDisposableCollection();
33
-
if(!this.isMounted){
34
-
// toggle the `isMounted` logic for the time being of the super call so that the `createRoot` does not run
// There is a bug in Theia, and the React component's `componentWillUnmount` will not be called, as the Theia widget is already disposed when closing and reopening a dialog.
27
+
// Widget lifecycle issue in Theia: https://github.com/eclipse-theia/theia/issues/12093
0 commit comments