I'm making a card game and trying to make a modification on a card.
My schema struct is somewhat like that:
field -> rows -> spots -> playerCard
My problem is, when I try to modify the object, the schema don't update, but when I move my card in the field for example, the values that I applied to the card finally appears.
I'm modifying the state like that:
this.state.field.rows[rowIndex].spots[spotIndex].playerCard.modifiers.push(playerCardModifier)
One workaround that I've been using is creating and entire new spot object (parent of my playerCard) and assiging it, this way the schema is properly updated.
The workaround is like this:
const tempSpot = new FieldSpot(spot.index, spot.ownerType)
tempSpot.playerCard = spot.playerCard
this.state.field.rows[rowIndex].spots[spotIndex] = tempSpot
Is there a way to make the state update without creating a new object?
I tried cloning the object with javascript spread operator, but that don't work for schemas, since spread just copy the enumerated values of an object.
Thanks in advance.