Fix crash during Source component removal (#928)

This commit is contained in:
Xiaoji Chen 2019-10-29 16:14:09 -07:00 committed by GitHub
parent 734b1114be
commit d1cb92dffd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,7 +48,12 @@ export default class Source<Props: SourceProps> extends PureComponent<Props> {
}
componentWillUnmount() {
this._map.removeSource(this.id);
/* global requestAnimationFrame */
// Do not remove source immediately because the
// dependent <Layer>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;