From 1c8da888b302bfc00e64c06269281740ea2e6815 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Tue, 12 Mar 2024 10:33:43 +0100 Subject: [PATCH] fix: avoid re-rendering an item when adding the same again This also avoids an unnecessary fetch of the same visualization object. --- src/components/Item/VisualizationItem/Item.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Item/VisualizationItem/Item.js b/src/components/Item/VisualizationItem/Item.js index 00aec655d..2be17f136 100644 --- a/src/components/Item/VisualizationItem/Item.js +++ b/src/components/Item/VisualizationItem/Item.js @@ -81,9 +81,13 @@ class Item extends Component { } async componentDidMount() { - this.props.setVisualization( - await apiFetchVisualization(this.props.item) - ) + // Avoid refetching the visualization already in the Redux store + // when the same dashboard item is added again. + // This also solves a flashing of all the "duplicated" dashboard items. + !this.props.visualization.id && + this.props.setVisualization( + await apiFetchVisualization(this.props.item) + ) try { if (