Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: always re-mount anywidgets to clear state (#4105)

Myles Scolnick9871289cf2ae
diff --git a/frontend/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx b/frontend/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx
index 8bd23e2d9a..a1b858f71a 100644
--- a/frontend/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx
+++ b/frontend/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx
@@ -129,7 +129,15 @@ const AnyWidgetSlot = (props: Props) => {
}
return (
- <LoadedSlot {...props} widget={module.default} value={valueWithBuffer} />
+ <LoadedSlot
+ // Use the jsUrl as a key to force a re-render when the jsUrl changes
+ // Plugins may be stateful and we cannot make assumptions that we won't be
+ // so it is safer to just re-render.
+ key={jsUrl}
+ {...props}
+ widget={module.default}
+ value={valueWithBuffer}
+ />
);
};