Context
Starting with version 2, React-Leaflet leverages the new Context API introduced in React v16.3.
The context Object has the following Flow type:
type LeafletContext = {
map?: Map,
pane?: ?string,
layerContainer?: ?LayerContainer,
popupContainer?: ?Layer,
}
The context provider and consumer are exported as LeafletProvider
and LeafletConsumer
, along with a withLeaflet(Component: ComponentType<*>) => ComponentType<*>
higher-order component factory that can be used to wrap custom components. This wrapper injects the context as the leaflet
prop.
All the controls and layers exported by React-Leaflet use this wrapper, your application should only need to use these APIs in specific cases.
Starting with version 2.3, the useLeaflet()
hook can also be used to access the LeafletContext
object.