Update geojson in <Source /> isn't shallowly and don't cause update #2366
Unanswered
larsgaardsoe
asked this question in
Q&A
Replies: 1 comment
-
It appears this has something to do with deep-compare. Adding an id attribute to each feature, and changing that attribute on each change might change the map |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to manage some inline geojson using react state, but changes isn't detected since it's a non shallow object. Instead I need to update another prop on the Source component. I could just change the key, but that makes the component remount and doesn't feel right. I made a simple hack by changing the promoteId prop on Source, and that does the trick, but there must be a better way.
I could also use
mapRef.current.getSource("my-layer").setData(newGeojson)
but I could like to keep the geojson in react state and doing it with react-map-glBeta Was this translation helpful? Give feedback.
All reactions