Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug? Dynamic sources and layers #195

Closed
lapidus opened this issue Apr 13, 2019 · 5 comments
Closed

Bug? Dynamic sources and layers #195

lapidus opened this issue Apr 13, 2019 · 5 comments

Comments

@lapidus
Copy link

lapidus commented Apr 13, 2019

I am rendering a dynamic list of Sources and Layers:

// inside react render ... 

{ sources.map(s => (
    <Source [some props] />
))}
{sources.map(s => (
     <Layer [some props] />
))}

This works well on load but when I subsequently filter sources, I get this type of error:

Source "primary" cannot be removed while layer "primary" is using it

image

It seems the mapbox operation under the hood is asynchronous so that I cannot delete a source in the same render as I delete a layer. How can I work around this? Or could you possibly build in some safeguards against this behaviour?

Thanks!

@lapidus lapidus changed the title Mapping Bug? Dynamic sources and layers Apr 13, 2019
@stepankuzmin
Copy link
Member

Hi @lapidus! Thanks for the issue!

What version do you use? Could you please provide a reproducible example?

@lapidus
Copy link
Author

lapidus commented Apr 14, 2019

Hi!

It seems they had the same issue here:
alex3165/react-mapbox-gl#493

And resolved by removing layers before sources:
alex3165/react-mapbox-gl@986b555

@lapidus
Copy link
Author

lapidus commented Apr 14, 2019

I could try to do a PR later, any hints appreciated :)

@lapidus
Copy link
Author

lapidus commented Apr 14, 2019

Gah, gosh! I just realized you fixed this 6 days ago:
3f228af#diff-c4273adc64deb9bc0ebb2446633a17cd

I was still on version 1.3. Sorry about that and thank you for a great lib!

@lapidus lapidus closed this as completed Apr 14, 2019
@stepankuzmin
Copy link
Member

No problem, glad to hear that this worked for you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants