Open high1 opened 6 years ago
How it looks with type definitions for TypeScript? When will it be supported please? Thanks
Considering it only inherits MapLayer
with no fancy whatever, something like this works:
declare module 'react-leaflet-markercluster' {
import {MapLayer} from 'react-leaflet'
export default class MarkerClusterGroup extends MapLayer {}
}
Edit: Don't forget, it's dependent on @types/react-leaflet
.
I am using react-leaflet-markercluster 3.0.0-rc1 and @types/react-leaflet-markercluster 2.0.0 and I get this in the code:
'MarkerClusterGroup' cannot be used as a JSX component. Its instance type 'MarkerClusterGroup
' is not a valid JSX element. Type 'MarkerClusterGroup ' is missing the following properties from type 'ElementClass': render, context, setState, forceUpdate, and 3 more. TS2786
Code is very simple, used the example:
<MarkerClusterGroup>
<Marker position={[49.8397, 24.0297]} />
<Marker position={[52.2297, 21.0122]} />
<Marker position={[51.5074, -0.0901]} />
</MarkerClusterGroup>
The index.d.ts clearly says that the definitions apply to v2.0, can we have something for 3.0.0?
Here is the definition for React Leaflet's FeatureGroup:
export declare const FeatureGroup: import("react").ForwardRefExoticComponent<FeatureGroupProps & import("react").RefAttributes<LeafletFeatureGroup<any>>>;
So I'm guessing that MarkerClusterGroup is something similar?
p.s. MapLayer is gone from React Leaflet v3 so it isn't as simple as @gwillz posted for v2.
Hi, what types do you use? I'm using "@types/react-leaflet-markercluster": "^3.0.0", and I have no way to set the events :(...
Missing type definitions for TypeScript.