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

Error removing layer when using mapbox-gl 0.43.0 #493

Closed
jthetzel opened this issue Jan 8, 2018 · 6 comments
Closed

Error removing layer when using mapbox-gl 0.43.0 #493

jthetzel opened this issue Jan 8, 2018 · 6 comments

Comments

@jthetzel
Copy link
Contributor

jthetzel commented Jan 8, 2018

Mapbox-gl v0.43.0 introduces a breaking change that throws an error if a source is removed while still in use (e.g. remove a source prior to removing layers that use the source, mapbox/mapbox-gl-js#5562 ). This was discovered in #491.

Example error:

mapbox-gl.js:546 Error: Source "example_id" cannot be removed while layer "example_id_marker" is using it.
    at t.removeSource (mapbox-gl.js:406)
    at e.removeSource (mapbox-gl.js:520)
    at Source.componentWillUnmount (source.js:71)
    at callComponentWillUnmountWithTimerInDev (react-dom.development.js:11117)
    at HTMLUnknownElement.callCallback (react-dom.development.js:1299)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:1338)
    at invokeGuardedCallback (react-dom.development.js:1195)
    at safelyCallComponentWillUnmount (react-dom.development.js:11125)
    at commitUnmount (react-dom.development.js:11415)
    at unmountHostComponents (react-dom.development.js:11356)
@jthetzel
Copy link
Contributor Author

jthetzel commented Jan 8, 2018

For reproducible example in example/demos, see toggle-layer demo at: jthetzel@4872734

@Wykks
Copy link
Contributor

Wykks commented Jan 9, 2018

Yup I had to deal with this change in ngx-mapbox-gl too (Wykks/ngx-mapbox-gl#10).
@alex3165 Instead of calling mapbox-gl method directly, we can buffer the removes request, then in the same frame after react work if possible process the removes in a defined order.

jthetzel added a commit to jthetzel/react-mapbox-gl that referenced this issue Jan 20, 2018
jthetzel added a commit to jthetzel/react-mapbox-gl that referenced this issue Jan 20, 2018
@alex3165
Copy link
Owner

Released with tag 3.5.0 of react-mapbox-gl

@redbmk
Copy link
Contributor

redbmk commented Feb 8, 2018

Odd - I'm still getting this error when using mapbox-gl 0.43.0 and react-mapbox-gl 3.5.0. Same with 0.44.0 and 3.5.1. I might be doing something a little differently than the examples. I'll see if I can tweak the them to reproduce this.

@redbmk
Copy link
Contributor

redbmk commented Feb 9, 2018

It turns out I was seeing the bug when swapping out tileJSON sources. I opened PR #530 to fix it.

@alex3165
Copy link
Owner

Published a fix from @redbmk in version 3.8.0, enjoy! 👍

mashtechk added a commit to mashtechk/react-mapbox-gl that referenced this issue Jan 23, 2021
preecedavid pushed a commit to preecedavid/React-Mapbox-gl that referenced this issue Mar 7, 2022
preecedavid pushed a commit to preecedavid/React-Mapbox-gl that referenced this issue Apr 28, 2022
kevin11290 pushed a commit to kevin11290/mar28 that referenced this issue Mar 28, 2023
peakgenius pushed a commit to peakgenius/react-mapbox-exam that referenced this issue Oct 12, 2023
crown0128 added a commit to crown0128/typescript-react-mapbox that referenced this issue Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants