Skip to content

Commit

Permalink
fix: avoid re-rendering an item when adding the same again (DHIS2-17016)
Browse files Browse the repository at this point in the history
This also avoids an unnecessary fetch of the same visualization object.
  • Loading branch information
edoardo committed Mar 13, 2024
1 parent 44cd380 commit 9b28b41
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/Item/VisualizationItem/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 9b28b41

Please sign in to comment.