diff --git a/src/components/source.js b/src/components/source.js index 062247c6..6efa8bf0 100644 --- a/src/components/source.js +++ b/src/components/source.js @@ -48,7 +48,12 @@ export default class Source extends PureComponent { } componentWillUnmount() { - this._map.removeSource(this.id); + /* global requestAnimationFrame */ + // Do not remove source immediately because the + // dependent s' componentWillUnmount() might not have been called + // Removing source before dependent layers will throw error + // TODO - find a more robust solution + requestAnimationFrame(() => this._map.removeSource(this.id)); } id: string;