I'm trying to add geoJSON into a react-map-gl map using typescript
here is my code
<Source id="my-data" type="geojson" data={data}>
<Layer {...layerStyles}/>
</Source>
the data
variable is a parsed JSON file so it is an object not
the error I get is
Overload 1 of 2, '(props: SourceProps | Readonly<SourceProps>): Source', gave the following error.
Type 'object' is not assignable to type 'string | Feature<Geometry, GeoJsonProperties> | FeatureCollection<Geometry, GeoJsonProperties> | undefined'.
Type '{}' is missing the following properties from type 'FeatureCollection<Geometry, GeoJsonProperties>': type, features
Overload 2 of 2, '(props: SourceProps, context: any): Source', gave the following error.
Type 'object' is not assignable to type 'string | Feature<Geometry, GeoJsonProperties> | FeatureCollection<Geometry, GeoJsonProperties> | undefined'. TS2769
123 | onViewportChange={(nextView:typeof viewport) => setViewport(nextView)}>
124 | {/* GeoJSON */}
> 125 | <Source id="my-data" type="geojson" data={data}>
| ^
126 | <Layer {...layerStyles}/>
127 | </Source>
128 | {markers}
And the type of the data props in the Source component is supposed to be an object as you can see from the documentation https://visgl.github.io/react-map-gl/docs/api-reference/source
if you need any more information please ask