Leaflet: Map container not found
In addition to @IvanSanchez's response, You could add the geolocation and L.map(...) code to componentDidMount() React lifecycle method (depending on what other goals you hope to achieve). You could also create and bind event handlers for location found as well.
This way must have been added the dom and leaflet can find it.
Happy to help with this if it's still unclear.
The <div id="leafletmap">
must be added to the dom before calling L.map('leafletmap')
.