Skip to content

Commit

Permalink
Add logic to prevent re-renders (flicker)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlarave committed Jan 20, 2023
1 parent b35f5b6 commit 7d033e5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/controls/adaptiveCardHost/AdaptiveCardHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ export const AdaptiveCardHost = (props: IAdaptiveCardHostProps): JSX.Element =>
currentAdaptiveCard.parse(cardPayload, serializationContextInstanceRef.current);

const renderedElement = currentAdaptiveCard.render();
currentRenderElement.innerHTML = "";
currentRenderElement.appendChild(renderedElement);

// If this isn't acceptable, we should compare the old template with the new template
if (renderedElement.outerHTML !== currentRenderElement.innerHTML) {
currentRenderElement.innerHTML = "";
currentRenderElement.appendChild(renderedElement);
}
} catch (cardRenderError) {
if (props.onError) {
props.onError(cardRenderError);
Expand Down

0 comments on commit 7d033e5

Please sign in to comment.