Skip to content

Markers update when Markers array is updated - possible? #362

Answered by usefulthink
kevinjavitz asked this question in Q&A
Discussion options

You must be logged in to vote

I suspect the problem here is that you aren't actually changing the identity of the markers array. React will basically only update if oldThing !== newThing, which isn't the case if you manipulate the array in place.

Can you give this a try: Instead of markers.pop(); setMarkers(markers);, use markers.pop(); setMarkers([...markers]);, creating a copy of the array before setting it as new state.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@usefulthink
Comment options

Answer selected by usefulthink
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants