Skip to content

Commit d7ebfbc

Browse files
committed
Fix crash in React 18 StrictMode (#1680)
1 parent 9a729c2 commit d7ebfbc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/mapbox/mapbox.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,20 @@ export default class Mapbox {
317317
// This eliminates the timing issue between calling resize() and DOM update
318318
/* eslint-disable accessor-pairs */
319319
const {container} = props;
320-
Object.defineProperty(container, 'offsetWidth', {get: () => this.width});
321-
Object.defineProperty(container, 'clientWidth', {get: () => this.width});
320+
Object.defineProperty(container, 'offsetWidth', {
321+
configurable: true,
322+
get: () => this.width
323+
});
324+
Object.defineProperty(container, 'clientWidth', {
325+
configurable: true,
326+
get: () => this.width
327+
});
322328
Object.defineProperty(container, 'offsetHeight', {
329+
configurable: true,
323330
get: () => this.height
324331
});
325332
Object.defineProperty(container, 'clientHeight', {
333+
configurable: true,
326334
get: () => this.height
327335
});
328336

0 commit comments

Comments
 (0)