From d1cb92dffdb06d1d100a02b0a7f11d68f869c6ad Mon Sep 17 00:00:00 2001 From: Xiaoji Chen Date: Tue, 29 Oct 2019 16:14:09 -0700 Subject: [PATCH] Fix crash during Source component removal (#928) --- src/components/source.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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;