Skip to content

Commit 726ab80

Browse files
allow user to control React wrapper id (visgl#6010)
1 parent bd85343 commit 726ab80

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

modules/core/src/lib/deck.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function getPropTypes(PropTypes) {
106106
}
107107

108108
const defaultProps = {
109-
id: 'deckgl-overlay',
109+
id: '',
110110
width: '100%',
111111
height: '100%',
112112

@@ -424,13 +424,12 @@ export default class Deck {
424424

425425
if (!canvas) {
426426
canvas = document.createElement('canvas');
427+
canvas.id = props.id || 'deckgl-overlay';
427428
const parent = props.parent || document.body;
428429
parent.appendChild(canvas);
429430
}
430431

431-
const {id, style} = props;
432-
canvas.id = id;
433-
Object.assign(canvas.style, style);
432+
Object.assign(canvas.style, props.style);
434433

435434
return canvas;
436435
}

modules/react/src/deckgl.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ const DeckGL = forwardRef((props, ref) => {
190190
const {viewManager} = thisRef.deck || {};
191191
const currentViewports = viewManager && viewManager.getViewports();
192192

193-
const {ContextProvider, width, height, style} = props;
193+
const {ContextProvider, width, height, id, style} = props;
194194

195195
const {containerStyle, canvasStyle} = useMemo(() => extractStyles({width, height, style}), [
196196
width,
@@ -221,14 +221,15 @@ const DeckGL = forwardRef((props, ref) => {
221221

222222
const canvas = createElement('canvas', {
223223
key: 'canvas',
224+
id: id || 'deckgl-overlay',
224225
ref: canvasRef,
225226
style: canvasStyle
226227
});
227228

228229
// Render deck.gl as the last child
229230
thisRef.control = createElement(
230231
'div',
231-
{id: 'deckgl-wrapper', ref: containerRef, style: containerStyle},
232+
{id: `${id || 'deckgl'}-wrapper`, ref: containerRef, style: containerStyle},
232233
[canvas, childrenUnderViews]
233234
);
234235
}

0 commit comments

Comments
 (0)