leaflet-tracking-marker icon indicating copy to clipboard operation
leaflet-tracking-marker copied to clipboard

TypeScript support

Open JeffinJ opened this issue 3 years ago • 6 comments

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.

JeffinJ avatar Mar 12 '22 09:03 JeffinJ

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!

alexandra-c avatar Mar 18 '22 08:03 alexandra-c

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?

GabrielMil avatar Aug 08 '22 11:08 GabrielMil

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 😊

alexandra-c avatar Aug 09 '22 06:08 alexandra-c

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!

GabrielMil avatar Aug 09 '22 07:08 GabrielMil

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} />

tomszafr avatar Aug 31 '22 21:08 tomszafr

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 😁

alexandra-c avatar Sep 01 '22 08:09 alexandra-c

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!

image

paveltretyakovru avatar Dec 13 '22 15:12 paveltretyakovru

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 ! 😁

alexandra-c avatar Dec 13 '22 15:12 alexandra-c