https://github.com/PaulLeCam/react-leaflet#technical-considerations have the following point:
Leaflet makes direct calls to the DOM when it is loaded, therefore this library is not compatible with server-side rendering.
I would like to discuss of the possibilities how it's possible to add server-side support for this library.
My current solution just skip rendering the leaflet on server-side, and render just on client-side:
render() {
const position = [51.505, -0.09];
if (process.env.BROWSER) {
var {Map, Marker, Popup, TileLayer} = require('react-leaflet');
return (
<div className="search-map">
<Map center={position} zoom={13}>
<TileLayer
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
/>
<Marker position={position}>
<Popup>
<span>A pretty CSS3 popup.<br/>Easily customizable.</span>
</Popup>
</Marker>
</Map>
</div>
);
}
else {
return null;
}
}
I don't believe it's a best practice, but still it's something, than nothing, and I think it's better than using the headless-leaflet fork.
https://github.com/PaulLeCam/react-leaflet#technical-considerations have the following point:
I would like to discuss of the possibilities how it's possible to add server-side support for this library.
My current solution just skip rendering the leaflet on server-side, and render just on client-side:
I don't believe it's a best practice, but still it's something, than nothing, and I think it's better than using the
headless-leafletfork.