Attempted import error: 'withLeaflet' is not exported from 'react-leaflet'
Asked Answered
D

0

2

Code:

import { withLeaflet} from "react-leaflet"; 

I just want to import the withLeaflet but it gives me this error

Error:

Attempted import error: 'withLeaflet' is not exported from 'react-leaflet'.

package.json >dependencies

"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"leaflet": "^1.7.1",
"leaflet-rotatedmarker": "^0.2.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-leaflet": "^3.0.2",
"react-leaflet-rotatedmarker": "^0.1.0",
"react-scripts": "4.0.1",
"web-vitals": "^0.2.4"
Dendroid answered 23/11, 2020 at 16:5 Comment(4)
you using react-leaflet 3, you no longer use withLeaflet, you need to use their hooks instead.Tolmach
react-leaflet.js.org/docs/api-map/#hooksTolmach
@Someone Special Thank you so much you was rightDendroid
So how do you change that code to work on v3? Can you please show that? I don't understand the documentation on hooks there, not sure what to do to make this work.Rocray

© 2022 - 2024 — McMap. All rights reserved.