-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
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
- Discussion: Uncontrolled Deck with new React Activity component #9921
- React Activity docs: https://react.dev/reference/react/Activity
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:
- Cleanup runs →
finalize()destroys the Deck instance and its internal view state - When shown again → A new Deck instance is created with the original
initialViewState - User's pan/zoom changes are lost
Environment
- Framework version: 9.2
- Browser: Chrome
- OS: MacOS
Logs
No response