[Maps] ensure resiveChecker exists before calling destroy (#30032)

This commit is contained in:
Nathan Reese 2019-02-04 22:02:53 -07:00 committed by GitHub
parent 9b1e2d454f
commit de2d0b647c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -53,7 +53,9 @@ export class MBMapContainer extends React.Component {
componentWillUnmount() {
this._isMounted = false;
this._checker.destroy();
if (this._checker) {
this._checker.destroy();
}
if (this._mbMap) {
this._mbMap.remove();
this._mbMap = null;
@ -65,6 +67,10 @@ export class MBMapContainer extends React.Component {
this._mbMap = await createMbMapInstance(this.refs.mapContainer, this.props.goto ? this.props.goto.center : null);
if (!this._isMounted) {
return;
}
// Override mapboxgl.Map "on" and "removeLayer" methods so we can track layer listeners
// Tracked layer listerners are used to clean up event handlers
const originalMbBoxOnFunc = this._mbMap.on;