Answer the question
In order to leave comments, you need to log in
How to call a function in Redux?
Good afternoon! Can you please tell me where in Redux such functions should be located (in a component, reducer ...)? Or how to rewrite them for redux?
getClusters = () => {
const clusters = supercluster(markersData, {
minZoom: 0,
maxZoom: 16,
radius: 120
});
return clusters(this.state.mapOptions);
};
createClusters = (props) => {
this.setState({
clusters: this.state.mapOptions.bounds
? this.getClusters().map(({wx, wy, img, numPoints, points}) => ({
lat: wy,
lng: wx,
numPoints,
id: `${numPoints}_${points[0].id}`,
img_path: img,
points
}))
: [],
});
};
Answer the question
In order to leave comments, you need to log in
it all depends on your task
for the web, I combine the state of the component and redux
for mobile almost everything in redax
did not work with google maps on the web, but usually the markers are collected in the cluster themselves (native android and mapbox js too)
I would keep the markers in the redax but on the map, let them decide how they will be displayed
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question