Skip to content

Commit

Permalink
Add check before setting prop (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
hblitza committed Apr 12, 2023
1 parent 4ddb6ad commit fb580e7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/component/FeatureInfoGrid/FeatureInfoGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export const FeatureInfoGrid: React.FC<ComponentProps> = ({
// Reset style for all (previous selected) features cf. hoverStyleFunction
source.getFeatures().forEach((f: OlFeature) => f.set('selectedFeat', false));
// Set selected feature style
source.getFeatureById(newFeat.getId())?.set('selectedFeat', true);
if (newFeat && newFeat.getId()) {
source.getFeatureById(newFeat.getId())?.set('selectedFeat', true);
}
};

/**
Expand Down

0 comments on commit fb580e7

Please sign in to comment.