Render ShapeSource
conditionally without not in style
error
#3580
Replies: 2 comments 2 replies
-
@andyl-ioki hi, it's very hard to know what's going on, based on the info you've provided. I really appreciate the effort that you've tried to repro in the example app. I would suggest you try to simplify the app, by commenting out other layers in the map. Ideally you can either end up with a simple component that you can copy paste as is to the example, or discover that what other layers/feature contributes to this issue. |
Beta Was this translation helpful? Give feedback.
-
@andyl-ioki thanks much, Ideally redux is not doing stuff that we can't reproduce with setState etc. But if you can repro with a simple component and simple redux setup that's a good direction already |
Beta Was this translation helpful? Give feedback.
-
Hej there!
At first: Thanks for this project 👍
Project setup
We are using
rnmapbox
v10.1.28
.In our project we have layers which render conditionally. So their
shape
might benull
and their shape changes often over time. The shape depends on the users interaction with the App and phone. Also the shape is saved to our state store and the Mapbox component reads it from there.As
ShapeSource
must have a non emptyshape
, we decided to use a simpleif
before returning the actualShapeSource
like:Current Problem
Since we migrated to
v10
the app creates errors, whenever we switch between both returns, e.g.:Solution
I checked the examples they always have at least a minimal shape. But for us this is not always the case.
So I tried to put in a fallback shape like
[0.0, 0.0], ...
and use thevisibility
property to just hide it, if we don't have any data for ourSymbolLayer
orLineLayer
.With this workaround the errors vanish completely.
Replication at RN Example App
I was not successful to replicate on the example app. 😢
The only thing I can come up with is, that it might be an race condition. We are doing many calculations on our App, changing a lot of lines here and there.
Maybe mapbox is not ready with adding the style or something at that point? 🤔
What I can give you is a near same example of what we similarily do in our App for the the example App:
Example code from `example/src/examples/Map/ShowAndHideLayer.js`
Question
Might this be a bug because we do something wrong?
Or is it kind of a race condition on the mapbox or rnmapbox side?
If you have any clue what I can investigate further or what we are doing wrong, let me know 👍
Beta Was this translation helpful? Give feedback.
All reactions