With <Activity mode="hidden">, React preserves state and DOM but unmounts all effects (every useEffect cleanup runs, just like an unmount). When the activity becomes visible again, the effects re-run. This is by design in React, not a Mantine bug — and it's why your console.log in a cleanup fires on every mouse leave.
So an effect inside VehicleBadgeToggle that calls e.g. map.addLayer(...) and cleans up with map.removeLayer(...) will keep adding/removing Mapbox points each time the HoverCard opens/closes. State is preserved, but side effects are not
The clean fix is to lift the Mapbox side effect out of the dropdown so it doesn't depend on HoverCard's visibility:
- Move the useEffect that inserts points on the map into a parent component that is always mounted (e.g., the component that owns the Badge / HoverCard). Drive its behavior off the same vehicle / followEvents data. The dropdown then renders only UI.
- Or, if the map points really must live with the toggle component, render VehicleBadgeToggle outside HoverCard.Dropdown and only render its UI portion inside the dropdown.