From 77cf118050638cb7f8a851e0ae00c1ebbe2e67d9 Mon Sep 17 00:00:00 2001 From: Kevin Mo Date: Tue, 3 Feb 2026 11:21:49 -0800 Subject: [PATCH] fix(react-maplibre): guard against undefined map.style in _updateStyleComponents When using React 19's Activity component with mode="hidden", the map can be in a partially initialized state when event handlers fire. This causes a TypeError when accessing map.style._loaded because map.style is undefined. Adding optional chaining prevents the crash while maintaining the same logical behavior - if map.style is undefined, the condition is falsy and the style components won't be updated (which is the correct behavior when the map isn't fully initialized). --- modules/react-maplibre/src/maplibre/maplibre.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/react-maplibre/src/maplibre/maplibre.ts b/modules/react-maplibre/src/maplibre/maplibre.ts index 4ef1122ad..fa16e53ad 100644 --- a/modules/react-maplibre/src/maplibre/maplibre.ts +++ b/modules/react-maplibre/src/maplibre/maplibre.ts @@ -462,7 +462,7 @@ export default class Maplibre { const map = this._map; const currProps = this._styleComponents; // We can safely manipulate map style once it's loaded - if (map.style._loaded) { + if (map.style?._loaded) { if (light && !deepEqual(light, currProps.light)) { currProps.light = light; map.setLight(light);