Luisa Repele
Luisa Repele

Reputation: 165

Uncaught Error: Element type is invalid: expected a string react-leaflet

I integrated react-leaflet on my project create with create-react-app scripts. I follow this example.

Everything works, but when I try use GeoJsoncomponent imported as:

import { Map, TileLayer, Popup, GeoJson } from 'react-leaflet'

I have the following warning.

warning.js:35 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check your code at index.js:47.

and error

Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of Leaflet

and I can't see the region on maps.

How can fix this? Thanks .

Upvotes: 0

Views: 682

Answers (1)

Shahar Sadkovich
Shahar Sadkovich

Reputation: 110

According to react-leaflet recent changes , You should try to import GeoJSON instead of GeoJson. It was changed in order to match the recent leaflet library change.

Upvotes: 1

Related Questions