Search code examples
javascriptreactjsmapsmapbox-glreact-map-gl

react-mapbox-gl Cluster not working


Cluster in react-mapbox-gl is giving error

I am able to plot markers without using cluster but with cluster it gives me this error:

supercluster_1.default is not a function

For this React code :

    <Map
        style={style}
        containerStyle={mapStyle}
        center={{ lng: -71.07636094093323, lat: 42.35034583215539 }}
        bearing={[20]}
        pitch={[40]}
        zoom={[1]}
    >

            <Cluster ClusterMarkerFactory={(coordinates) => {
                return (<Marker coordinates={coordinates} style={clusterMarkerStyle}>
                 <div>1</div>
                </Marker>)
            }}>
            {
                places.features.map((feature, key) =>
                    <Marker
                        key={key}
                        coordinates={feature.geometry.coordinates}
                        >
                        <Mark/>
                    </Marker>
                )
            }
            </Cluster>
        </Map>

Solution

  • Reinstalling the node_modules solved the problem.