I am stuck with a strange issue with React.
this.state={
testState: { testValue: "Test State" }
}
testFn = () => {
let a;
a = this.state.testState
a.testValue = "Debugging is awesome";
console.log(this.state.testState)
}
If I have made any change in the assigned variable a
, then it will reflect in the state also.
What I got in console is,
{testValue: "Debugging is awesome"}
.
Any help will be appreciable
Edit:
I don't want to change the state. I have to modify a
without altering the state. How can I achieve this?
testState
is an object and you're modifying it. What are you looking to achieve?