From d7ebfbc2cdeeea81f14bfb88a005bc87a2351da1 Mon Sep 17 00:00:00 2001 From: Xiaoji Chen Date: Mon, 10 Jan 2022 20:01:07 -0800 Subject: [PATCH] Fix crash in React 18 StrictMode (#1680) --- src/mapbox/mapbox.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mapbox/mapbox.js b/src/mapbox/mapbox.js index 8610f728..2e9f1fc0 100644 --- a/src/mapbox/mapbox.js +++ b/src/mapbox/mapbox.js @@ -317,12 +317,20 @@ export default class Mapbox { // This eliminates the timing issue between calling resize() and DOM update /* eslint-disable accessor-pairs */ const {container} = props; - Object.defineProperty(container, 'offsetWidth', {get: () => this.width}); - Object.defineProperty(container, 'clientWidth', {get: () => this.width}); + Object.defineProperty(container, 'offsetWidth', { + configurable: true, + get: () => this.width + }); + Object.defineProperty(container, 'clientWidth', { + configurable: true, + get: () => this.width + }); Object.defineProperty(container, 'offsetHeight', { + configurable: true, get: () => this.height }); Object.defineProperty(container, 'clientHeight', { + configurable: true, get: () => this.height });