F
F
fronter-up2017-10-13 09:34:31
JavaScript
fronter-up, 2017-10-13 09:34:31

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
                }))
                : [],
        });
    };

These functions define clusters on google maps.
Should the map component have its own state or should it receive data exclusively from props?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Gamega, 2017-10-13
@gadfi

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

A
Alexander, 2017-10-13
@kentuck1213

In action games. redux.js.org/docs/basics/Actions.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question