Skip to content

Commit f9a0a62

Browse files
authored
Fix widget persistence in React development mode (#30509)
15f1291 was really close to making widgets just work again in React development mode following the upgrade to React 19, but I forgot to test one thing: that persistent widgets (such as Element Call) still reuse the same iframe across their entire lifecycle as expected. The solution is to not manually destroy the iframe when AppTile is being unmounted; even if it turns out that the widget isn't actually persistent, React will still destroy it automatically for us.
1 parent d7f5435 commit f9a0a62

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/components/views/elements/AppTile.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,12 @@ export default class AppTile extends React.Component<IProps, IState> {
445445
* Callback ref for the parent div of the iframe.
446446
*/
447447
private iframeParentRef = (element: HTMLElement | null): void => {
448+
if (this.unmounted) return;
448449
// Detach the existing iframe (if any) from the document so we know not
449450
// to do anything further with it, like starting up the messaging
450451
this.iframeParent?.querySelector("iframe")?.remove();
451452
this.iframeParent = element;
452-
if (this.unmounted) return;
453+
453454
if (element && this.sgWidget) {
454455
this.startMessaging();
455456
} else {

0 commit comments

Comments
 (0)