Stan
Stan

Reputation: 11

React-leaflet does not work using create-react-app and react 16.8.4

I'm trying to get a basic example of react-leaflet 2.2.1 to work with the latest react release, 16.8.4. However, the leaflet map does not display correctly.

I used create-react-app to create a new project, then modified the App.jsx to include a component that is identical to the codepen example given for react-leaflet. The only change is to the containing div where I specified the height & width.

The map tiles do not render within the div and instead end up in somewhat random positions. enter image description here

The entire app code in https://github.com/sknutsonsf/agdex/tree/master/src

This looks like some kind of compatibility issue with the new react version.

Upvotes: 0

Views: 802

Answers (1)

Eduardo Nishizuka
Eduardo Nishizuka

Reputation: 54

I had the same issue, adding

import 'leaflet/dist/leaflet.css';

solved my problem

Upvotes: 0

Related Questions