Skip to content

Commit

Permalink
Fix: ensuring we always render the latest app state
Browse files Browse the repository at this point in the history
  • Loading branch information
stevematney committed Jan 27, 2023
1 parent 9591369 commit 235980f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ReactHTMLElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class ReactHTMLElement extends HTMLElement {

private _awaitingRoot = false;

private _app: Renderable | undefined;

private getShadowRoot(): ShadowRoot {
return this.shadowRoot || this.attachShadow({ mode: 'open' });
}
Expand Down Expand Up @@ -72,8 +74,9 @@ class ReactHTMLElement extends HTMLElement {
}

async renderRoot(app: Renderable): Promise<void> {
this._app = app; // this value may change while we wait for root...
const root = await this.root();
root.render(app);
root.render(this._app); // always render current app
}

disconnectedCallback(): void {
Expand Down

0 comments on commit 235980f

Please sign in to comment.