How to import react libraries on custom component properly in retool?

Hey there, so I am using retool’s custom component to render my react app.
Currently I have been following the template but whenever I add

const {Map, Marker, Popup, TileLayer}  = window["react-leaflet"];

This is the script

<script src="https://cdnjs.cloudflare.com/ajax/libs/react-leaflet/2.7.0/react-leaflet.min.js"></script>

I have read the documentation, and I am still confused on how to import this correctly as well…

Hey!

I took a look at the library you’re trying to use. They have some documentation under “UMD” that’s relevant for you. I think you want to reference the library like this: window["ReactLeaflet"]. In general, it’s not possible to infer how to grab a reference to the library from the window object.

Let us know if we can help out any more :slight_smile:

2 Likes