leaflet-tracking-marker
leaflet-tracking-marker copied to clipboard
TypeScript support
JSX element class does not support attributes because it does not have a 'props' property. 'LeafletTrackingMarker' cannot be used as a JSX component. Its instance type 'LeafletTrackingMarker' is not a valid JSX element.
Can you please add a reproduction sample, maybe in SandBox? Also I encourage everyone to contribute however they can, if you know how to fix this issue you can create a pull request and become a contributor 😊. Thank you!
Hello there, I'm having the same problem. Is it possible to give please an example of how to use this package with react-ts. How to create the .tsx file with the LeafletTrackingMarker. Thanks.
BTW, does it matter if I'm using react-leaflet 4.0.1?
Hello, I'm working on this issue, I'm not sure how to make it compatible with ts. I wrote this library back when I didn't know typescript that much, I'm thinking about rewriting it with typescript now, which will also fix this issue and will also improve the code and build quality. If you have any ideas I'm open to suggestions.
I'm also using LTS version of react-leaflet, 4.0.1 works just fine for me. 😊
Thanks 😊
Nice to hear that, I wish you good luck and I'll stay tuned! I wish I could help but I'm still learning typescript :( Keep up the great work!
Hi, thought I might help with the types. Here's the PR.
LeafletTrackingMarkerElement might be useful when using refs:
import { LeafletTrackingMarker, LeafletTrackingMarkerElement } from "react-leaflet-tracking-marker";
(...)
const markerRef = useRef<LeafletTrackingMarkerElement>(null);
(...)
<LeafletTrackingMarker ref={markerRef} />
Thank you for your contribution @tomszafr! Does your PR fixes the TypeScript support issue?
I'm working on rewriting the whole thing with TypeScript, react-leaflet 4 and react 18...but I got stuck fixing a 'useContext' react hook error... I'm going to push my current changes in a separate branch if anyone is interested and can help me, it would be hugely appreciated 😁
Aloha :) With previous version of types I can't use children property with the wonderful component. Current changes extend react-leaflet marker properties to supporting children property for using popup (for example) with the component. Please, look at the Pull Request And thank so much for the library, you have saved my time!

Hello, @paveltretyakovru! Thank you for contributing, I wish to fully rewrite it with typescript but unfortunately my time is so limited.... I'm so glad people are contributing though. Thanks ! 😁