code-for-charlottesville/cville-streetlights-web-app

Replace current Marker key with true unique ID

Opened this issue · 1 comments

Currently, we just rely on the index of the data piece in the GeoJSON file for the unique key that is associated with each marker. As we add features like filtering, the total number of elements being rendered will change, which will cause the key values to change for all markers, which will cause React to destroy and re-create the scope for that marker and re-render (which is unnecessarily expensive). We should add a UID to each row in the GeoJSON. As this code is being run on the client machine, we don't want to add a unique ID to each row "in post" in the client code.

https://github.com/code-for-charlottesville/cville-streetlights-web-app/blob/main/src/components/MainMap.js#L45

Yes, good point. I'll add that to the list of action items.