4 ms·
Someone made a nice wrapper for react I've been using with good success. https://github.com/PaulLeCam/react-leaflet https://github.com/PaulLeCam/react-leaflet
by rhcom2 9y ago
Someone made a nice wrapper for react I've been using with good success.
https://github.com/PaulLeCam/react-leaflet https://github.com/PaulLeCam/react-leaflet
- k__ 9y agoDidn't have a good experience with this kind of React wrappers, I used a Leaflet wrapper for a few years. They always lack behind and try to force the React lifecycle and composition onto the library. Often this leads to leaking abstractions, which get uglier and uglier with time. Updating is also not a charm. I stopped using them and simply build one component as facade, then use props as interfaces to the lib while letting the lib do its thing the way it wants behind that component.
- smrq 9y agoNot to discount your experience, which is pretty consistent with my own, but what you've just described is writing your own wrapper component. I think there's something to be said for doing it yourself, particularly when the available options make you have to care about their internals anyway. But perhaps some of that effort might be put towards making a better open-source wrapper.
- mhink 9y agoI've worked a little bit with libraries like this (react-mapbox-gl) and I think the point GP is making is more like this: <3P.Wrapper> <3P.Foo> <3P.Bar subcomponent={props} /> </3P.Foo> { someCondition ? <3P.Quux onCrunch={doQuack}{ /> } </3P.Wrapper> where mounting and unmounting those child components interacts with the wrapped API. Contrast that with <3P.BasicWrapper useFoo useBar useQuux={someCondition} onQuuxCrunch={doQuack} /> which is less suitable for generic use, but easy enough to write (and modify later) that you probably don't need a highly-generic wrapper.
- k__ 9y agoThere is a difference between creating one component as entry to the lib and using React for the whole state management.
- aj_g 9y agoI've had the same experience. Especially if you get into using more and more niche packages (plugins for Leaflet), it can get ugly pretty fast.
- k__ 9y agoAnd if you need many customizations