I'm importing redux store and using the spread operator to create a copy of store property. Then when I change this copy, the original property also changes.
When I use copy = JSON.parse(JSON.stringify(original))
everything works fine.
export const move = (moveData: IMove): BoardActionTypes => {
const { board } = store.getState();
console.log(board.pieces.byId["19"]); // {row: 3, col: 7}
const newById: IPiecesById = { ...board.pieces.byId };
newById["19"].col = 4;
newById["19"].row = 4;
console.log(board.pieces.byId["19"]); // {row: 4, col: 4}
console.log(newById["19"]); // {row: 4, col: 4}
//...
};