Skip to content

Commit

Permalink
Merge pull request #16 from newrelic-experimental/bug-unkown-region
Browse files Browse the repository at this point in the history
Return null region data after hooks have been applied
  • Loading branch information
jsbnr committed Jun 19, 2024
2 parents d1c3abb + 5106f7a commit e16c8e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "location-geo-map",
"version": "2.3.1",
"version": "2.3.2",
"scripts": {
"start": "nr1 nerdpack:serve",
"prettier": "prettier --write ."
Expand Down
17 changes: 10 additions & 7 deletions visualizations/store-map-viz/components/Region.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ const Region = ({
const { regionColors } = useProps();
const { customColors } = useCustomColors(regionColors, false);

if (!regionFeature) {
console.log("Region not found for data, will not render", location);
return null;
}


const gradientColor = getGradientColor(location.value);

const style = useMemo(() => {
Expand Down Expand Up @@ -53,18 +49,20 @@ const Region = ({
location.status,
]);



// determine the tooltip title, memoized to avoid unnecessary recalculations
const getTooltipTitle = () => {
if (location.tooltip_header === "NONE" || location.tooltip_header === "") {
return null;
}
return location.tooltip_header
? location.tooltip_header
: regionFeature.name;
: regionFeature?.name;
};
const tooltipTitle = useMemo(getTooltipTitle, [
location.tooltip_header,
regionFeature.name,
regionFeature?.name,
]);

// extracted onClick handler
Expand All @@ -74,6 +72,11 @@ const Region = ({
}
};

if (!regionFeature) {
console.log("Region not found for data, will not render", location);
return null;
}

return (
<GeoJSON
key={key + "-" + location.value + "-" + style.fillColor}
Expand Down

0 comments on commit e16c8e4

Please sign in to comment.