Skip to content

[Bug] React 19 Activity component support #9983

@chrisgervang

Description

@chrisgervang

Description

Summary

deck.gl's React component doesn't properly support React 19's <Activity> component. When a <DeckGL> component is hidden via Activity and then shown again, the view state resets to initialViewState, losing any user interactions (pan/zoom).

Background

React 19.2 introduced the <Activity> component which hides components without unmounting them. However, Activity has a specific behavior: effect cleanup functions run when hidden, and effects re-run when visible again (while React state is preserved).

Related

Flavors

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

Expected Behavior

Deck should retain state in the hidden activity mode.

Steps to Reproduce

https://github.com/mohadib/deck-activity

This example has 2 maps and a div you can toggle between. One map uses an Activity, and the other uses css display: none when hidden. The css hiding retains state, the activity does not.

Root Cause

The DeckGL component's initialization effect (modules/react/src/deckgl.ts:189-199):

useEffect(() => {
  thisRef.deck = createDeckInstance(thisRef, DeckClass, {...});
  return () => thisRef.deck?.finalize();
}, []);

When Activity hides the component:

  1. Cleanup runs → finalize() destroys the Deck instance and its internal view state
  2. When shown again → A new Deck instance is created with the original initialViewState
  3. User's pan/zoom changes are lost

Environment

  • Framework version: 9.2
  • Browser: Chrome
  • OS: MacOS

Logs

No response

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions