performant-software / react-components

A library of shared React components
https://performant-software.github.io/react-components/
MIT License
1 stars 1 forks source link

Added handling for null geometry field #265

Closed ajolipa closed 7 months ago

ajolipa commented 7 months ago

In this PR

Improves the error handling of the PlaceMarker component to simply return null rather than throw page-breaking errors when the object fetched from Core Data has no value in the geometry field, addressing Issue #258 .

Notes

For now the simplest seemed to be to just add this case to the check for the existence of overall place data. The behavior seems to be that since the PlaceMarker component returns null, the map simply renders as a world atlas with no place highlighted, which seems like reasonable default behavior to me but obviously could be modified further if desired.

ajolipa commented 7 months ago

I believe that with the update to the PlaceMarkers component this is no longer an issue; in the current version, the response from Core Data is being fed into the feature or featureColleciton function from turf, which in the case that the geometry data passed in is null will return an empty array of features. This will then fail the new check _.isEmpty(data?.features and thus the component will return null rather than trying to render the LocationMarkers component. If that seems like reasonable/desired behavior, then I think this PR can be closed.

ajolipa commented 7 months ago

Closing (this is an older version of PR #269 ).