I was able to get the map reference using const map = useRef (null) but now I need to have some popup open when I start the map;
const map = useRef (null);
<MapContainer
zoom={15}
center={state.currentLocation}
whenCreated={(mapInstance) => {
map.current = mapInstance;
}}
>{listFarol.map((place) => {
return (
<>
<Marker
key={place.id}
position={place.pos}
icon={myIcon}
>
{place.name=== 'A' ? (
<Popup >{place.name}</Popup >
) : <Popup >{place.name}</Popup >}
</Marker>
</>
);
})}
<LocationMarker position={installActive} /></MapContainer>
But in case you want to use this reference to be able to define a series of popups that I want when the app starts open, in my case those that meet the condition place.name === 'A'
Define a custom Marker comp which will have the popup open
Then create a ternary for instance to decide which marker comp will be used during the loop:
You can even improve this by providing a flag on the markers array and not checking the popup name explicitly
Here is a simplified demo