Yomguithereal / react-blessed

A react renderer for blessed.
MIT License
4.45k stars 177 forks source link

console.log('screen was destroyed!') in 0.7.1 release #119

Closed groner closed 3 years ago

groner commented 3 years ago

Hi @Yomguithereal,

Thanks for the 0.7.1 release.

It looks like some debug noise got into the released build. The source maps in the build show the following changes when compared to my checkout of 0.7.1.

--- ../src/fiber/fiber.js
+++ node_modules/react-blessed/dist/index.js.map#../src/fiber/fiber.js
@@ -222,18 +222,16 @@
   return function render(element, screen, callback) {
     screenRef = screen;

-    // TODO: doesn't this leak? Shouldn't we use some weak map?
     let root = roots.get(screen);
     if (!root) {
       root = BlessedReconciler.createContainer(screen);
       roots.set(screen, root);
-
-      screen.once('destroy', () => {
-        BlessedReconciler.updateContainer(null, root, null);
-        roots.delete(screen);
-      });
     }

+    screen.once('destroy', () => {
+      console.log('screen was destroyed!');
+    });
+
     // render at most every 16ms. Should sync this with the screen refresh rate
     // probably if possible
     screen.debouncedRender = debounce(() => screen.render(), 16);
Yomguithereal commented 3 years ago

There is something weird indeed. The actual source on the repo is not the one that was built and shipped. Let me fix this quickly in a 0.7.2 release.

Yomguithereal commented 3 years ago

v0.7.2 is live on npm and should hopefully fix your issue. I was bitten by the changes npm made to the prepublish script.

groner commented 3 years ago

Looks good. Thanks again.