Once we added the Marker, the first thing we noticed is it didn't work! 😱
We can fix this though by overriding the library's default images with images imported straight from the library itself. It sounds confusing, but we'll walk through this together and see it not working on the page.
Colby Fayock: [0:00] It turns out the tools like create-react-app work is they're not able to produce the right location for each of our images. To fix that, we're going to override some of the Leaflet defaults to fix our marker images. To do that, we're going to use a useEffect hook.
[0:11] We'll first import that where we'll set up an instance of it with a new function and an empty dependency array. Inside that, we'll paste the code snippet we found in the GitHub issue. First, we're going to delete this default, and we're going to set up some new ones with the imports directly from Leaflet.
[0:24] Finally, since we're using Leaflet here, we have to import it. At the top we're going to import L from 'leaflet'. Now, if we open back up our map, we can see our marker.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!