ThomasThiebaud ThomasThiebaud - 3 months ago 41
React JSX Question

react-leaflet map not correctly displayed

I'm trying to use

to display a map. I use the code from this fiddle which is working, but on my computer I have this output

enter image description here

Here is my code :


import React from 'react'
import { Map, Marker, Popup, TileLayer } from 'react-leaflet';

export class DeviceMap extends React.Component {
constructor() {
this.state = {
lat: 51.505,
lng: -0.09,
zoom: 13,

render() {
const position = [, this.state.lng];
return (
<Map center={position} zoom={this.state.zoom} scrollWheelZoom={false}>
attribution='&copy; <a href="">OpenStreetMap</a> contributors'
<Marker position={position}>
<span>A pretty CSS3 popup. <br/> Easily customizable.</span>

export default DeviceMap


export class DeviceTabs extends React.Component {
state = {
index: 0

handleTabChange = (index) => {
this.setState({ index })

render () {
return (
<Tabs index={this.state.index} onChange={this.handleTabChange}>
<Tab label='Values'>
<DeviceTable {...this.props} />
<Tab label='Map'>
<div className={style.leaflet}>
<DeviceMap />


.leaflet {
height: 300px;
width: 100%;

There is no error in the console, and I have no more idea where to search. Since the fiddle is working it is not a bug. Did I miss something ?


Looks like you haven't loaded in the Leaflet stylesheet.

From the react-leaflet github guide:

If you are not familiar with Leaflet, make sure you read its quick start guide before using this library. You will notably need to add its CSS to your page to render the map properly, and set the height of the container.

Here is what you'll need:

<link rel="stylesheet" href="" />