Description
In the following snippet:
<MapGLMarker
latitude={location.coordinates.latitude}
longitude={location.coordinates.longitude}
anchor="bottom"
style={{
...(condition
? { background: 'red', }
: { background: undefined, }), // Note: similar problem if just passing {}
}}
>
Expected Behavior
When condition goes from true to false, the background attribute is un-set on the element.
Steps to Reproduce
Reproduction: https://codesandbox.io/p/sandbox/long-rgb-6f4mdv
Code snippet
import * as React from "react";
import { createRoot } from "react-dom/client";
import Map, { Marker } from "react-map-gl";
import "mapbox-gl/dist/mapbox-gl.css";
function Root() {
const [state, setState] = React.useState(false);
return (
<>
<button onClick={() => setState(!state)}>
background: {state ? "on" : "off"}
</button>
<Map
initialViewState={{
latitude: 37.8,
longitude: -122.4,
zoom: 14,
}}
style={{ width: "100vw", height: "100vh" }}
mapStyle="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
>
<Marker
longitude={-122.4}
latitude={37.8}
style={{
...(state ? { background: "red" } : { background: undefined }), // Note: similar problem if just passing {}
}}
/>
</Map>
</>
);
}
/* global document */
createRoot(document.getElementById("app")).render(<Root />);
Environment
- Framework version: react-map-gl@8.1.1 (in my project; reproduction template used
^7.1.0)
- Map library: mapbox-gl@3.24.0
- Browser: (not relevant)
- OS: (not relevant)
Logs
No logging produced
Description
In the following snippet:
Expected Behavior
When condition goes from
truetofalse, thebackgroundattribute is un-set on the element.Steps to Reproduce
Reproduction: https://codesandbox.io/p/sandbox/long-rgb-6f4mdv
Code snippet
Environment
^7.1.0)Logs
No logging produced