Skip to content

[Bug] widget appears multiple time in react StrictMode #9957

@amarant

Description

@amarant

Description

When in react strict mode the widget when added with react element, appear multiple time, and are re-added every time you interact with the map without being deleted so you can have tons of the same widget added :

also when looking at the code of useWidget :

if (index && index !== -1) {

should be to not confuse a widget at index 0 and an undefined

if (index !== undefined && index !== -1) {

but it doesn't solve the problem

Flavors

  • Script tag
  • React
  • Python/Jupyter notebook
  • MapboxOverlay
  • GoogleMapsOverlay
  • CARTO
  • ArcGIS

Expected Behavior

widget should appear a single time per react component

Steps to Reproduce

<React.StrictMode>
<DeckGL
        style={{ position: 'absolute', top: '0', left: '0' }}
        width="100%"
        height={mapHeight}
        layers={layers}
        controller
        initialViewState={INITIAL_VIEW_STATE}
        onViewStateChange={(vs) => setViewState(vs.viewState)}
>
        <ReactMapGl mapStyle={mapStyle} />
        <FullscreenWidget />
        <ZoomWidget />
</DeckGL>
</React.StrictMode>
Image

Environment

  • Framework version: 9.2
  • Browser: chrome 141
  • OS: Linux

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions