I am working on a reactJS application using TypeScript. I have created a class:
export class A{
showLegend: boolean = true;
showToolTip:boolean = true;
showDataLabel:boolean = false;
legendText: string = "Smith-Chart";
showAnimation:boolean = false;
legendPosition:string = "Bottom";
showMarker:boolean = true;
showMarkerLines:boolean = true;
linesColor:string = "";
markerColor:string = "";
markerBorderColor:string = "";
markerBorderWidth:number = 2;
}
My props has two objects of this class:
let localCopy : A[]
constructor(props: any){
super(props);
localCopy = this.props.slice;
}
This does copy the data into the localCopy
array, but when i update the localCopy
, the actual props are also updated.
How can i copy the props my value and not by reference ?