$ show visgl/react-map-gl
react-map-gl is a TypeScript React component library that wraps Mapbox GL JS and MapLibre GL JS behind a declarative, reactive API. It does not render maps itself; instead it owns the lifecycle of native map instances and exposes components (Map, Marker, Popup, Source, Layer), controls such as NavigationControl and GeolocateControl, and hooks (useMap, useControl, MapProvider) that synchronize React props with the imperative map engine. The package is structured as a monorepo: a main aggregator package re-exports two per-backend packages, @vis.gl/react-mapbox and @vis.gl/react-maplibre, plus a legacy Mapbox adapter. The current line is an alpha rewrite (v8.1.0-alpha.2) focused on performance, full typing, and 1:1 prop mapping with the native map libraries.
The LLM identified 3 files worth highlighting for reuse:
Converts between Mapbox/MapLibre internal transform objects and React view-state props (longitude, latitude, zoom, bearing, pitch), and applies view-state changes back onto a transform with zoom and pitch constraints. These pure functions are the core of the controlled-map data flow and can be reused in any imperative-to-reactive map wrapper.
Applies a React CSSProperties object to a DOM element, correctly handling unitless CSS properties and avoiding unnecessary style writes by tracking the previous style. It is an isolated utility with no internal module dependencies beyond React types, making it directly portable to any project managing imperative DOM nodes.
Normalizes map style objects - plain style objects, style URLs, and immutable-style structures with a toJS method - into a form that can be shallow-diffed for updates. This solves a recurring problem in map tooling: accepting multiple style representations while only triggering updates when actual style content changes.