Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
updateState({props, oldProps, changeFlags}) {
if (
changeFlags.dataChanged ||
(changeFlags.updateTriggers && changeFlags.updateTriggers.getHexagon)
) {
let resolution = -1;
let hasPentagon = false;
const {iterable, objectInfo} = createIterable(props.data);
for (const object of iterable) {
objectInfo.index++;
const hexId = props.getHexagon(object, objectInfo);
// Take the resolution of the first hex
resolution = resolution < 0 ? h3GetResolution(hexId) : resolution;
if (h3IsPentagon(hexId)) {
hasPentagon = true;
break;
}
}
this.setState({
resolution,
edgeLengthKM: resolution >= 0 ? edgeLength(resolution, UNITS.km) : 0,
hasPentagon
});
}
this._updateVertices(this.context.viewport);
}