alex3165 / react-mapbox-gl

A React binding of mapbox-gl-js
http://alex3165.github.io/react-mapbox-gl/
MIT License
1.93k stars 536 forks source link

MobX integration best practices #577

Open hyperknot opened 6 years ago

hyperknot commented 6 years ago

Is anyone using this library with MobX?

So far I'm having trouble how can I integrate with the [zoom] array for example. If I do

zoom={mapUIStore.zoom.toJS()}

where mapUIStore.zoom is an observable.array, it doesn't work. By this I mean that

  1. setting zoom to a new value -> works
  2. scroll zooming the map to a different value
  3. setting zoom to the same value -> doesn't work, as it's already set to the same value.

When [zoom] is used with setState is the state updated behind-the-scenes?

At this point, what do you recommend me to do? Should I just use the native zoomTo and forget about the auto-syncing [zoom] array magic?

janbaykara commented 6 years ago

I've been using Uber's react-map-gl to apply viewport updates reliably, and then continuing with react-mapbox-gl for its layer components: See #572