From 3d42bbe4f3ee1cf96ae18dc2a36799e0a222415a Mon Sep 17 00:00:00 2001 From: Willian Viana Date: Tue, 3 Dec 2024 11:28:51 -0300 Subject: [PATCH] fix(widget): add optional chaining to avoid error from re-render --- .../widgets/forest-change/tree-loss-plantations/selectors.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/widgets/forest-change/tree-loss-plantations/selectors.js b/components/widgets/forest-change/tree-loss-plantations/selectors.js index c63206ecef..bd1f4816e7 100644 --- a/components/widgets/forest-change/tree-loss-plantations/selectors.js +++ b/components/widgets/forest-change/tree-loss-plantations/selectors.js @@ -54,7 +54,8 @@ export const parseData = createSelector( areaLoss: summedPlatationsLoss || 0, totalLoss: totalLossForYear.area || 0, outsideCo2Loss: - totalLossByYear[d.year][0].emissions - summedPlatationsEmissions, + totalLossByYear[d.year]?.[0]?.emissions - + summedPlatationsEmissions, co2Loss: summedPlatationsEmissions || 0, }; return returnData;