I have an initial state with objeto item
to save the character data. equal const model = this.state.item
to be able to obtain the object and make modifications but it seems to create a reference and not a copy. when I modify var body
which is the object I use to delete and add model elements, this is also modified this.state.item
net.on('click', ev => {
if (!ev.shape) {
const model = this.state.item
var body = model.item.getModel()
delete body.shape;
const perid = body.id;
delete body.id;
body.per_id = perid;
body.source = perid;
var params = {
headers: {
"Content-Type": "application/json"
},
method: "POST",
body
}
cfetch(params);
The problem I have is that when I get the this.state.item
it is modified and I want it not to change just making a copy in const model
.