Check out the code snippet below:
const saveReserve = () => {
if (polygons && creatingPolygon) {
let last = creatingPolygon.coordinates[creatingPolygon.coordinates.length - 1][0][0];
console.log({last, polygons})
let newline = polygons. Coordinates[0][0].push(last);
console.log({newLine})
let oldArray: reservaLegal = {
coordinates: [
polygons.coordinates[0],
creatingPolygon.coordinates[0]
],
type: "MultiPolygon",
};
setPolygons(oldArray);
dispatch(saveLegalReserve(oldArray));
setCreatingPolygon(null);
} else {
setPolygons(creatingPolygon);
dispatch(saveLegalReserve(creatingPolygon));
setCreatingPolygon(null);
}
};
Whenever this function is called, it causes an error displayed on line 111 of the screen.
let newline = polygons. Coordinates[0][0].push(last);:
https://i.sstatic.net/ejetq.png
This leads to an error in the console as well:
ERROR TypeError: cannot add a new property, js engine: hermes
How should I resolve this issue? It seems confusing to me.