kadoshms / react-jvectormap

A react wrapper for jvectormap maps
MIT License
98 stars 70 forks source link

Series change does not rerender the vectormap #106

Closed alperensavaskan closed 2 years ago

alperensavaskan commented 2 years ago

I'm fetching data from API and want to render the map by response data. But it doesnt rerender after api fetch and setting new state

const [mapDataValues, setMapDataValues] = useState([]);

const mapData = {
        regions: [
            {
                values: mapDataValues,
                scale: ["#AAAAAA", "#444444"],
                normalizeFunction: "polynomial"
            }
        ]
    }

 useEffect(() => {
       getDataFromAPI().then(res => {
            setMapDataValues(res.data)
        })    
      }, []);

 <div style={{width: "100%", height: 500}}>
<VectorMap map={trMill}
                                               backgroundColor="white"
                                               series={mapData}
                                               regionStyle={regionStyle}
                                               regionsSelectable={true}
                                               regionsSelectableOne={true}

                                    />
</div>
kadoshms commented 2 years ago

Fixed here bb53b5468881bc6f16a1c625f7d143e9b8143ca0 and published:

 - @react-jvectormap/core: 1.0.0-alpha.6 => 1.0.0-alpha.7
 - @react-jvectormap/lib: 1.0.0-alpha.3 => 1.0.0-alpha.4

Please update - @react-jvectormap/core