I am trying to reuse an object in different components so my initial obj. is empty but when i export it into my component and setState to obj., it doesn't clear the state. but when I console.log the obj., it comes back as expected. any idea why this is happening?
this.state = {
name: '',
lastName: '',
age: 0,
kids: 0
}
const myEmptyObj = {
name: '',
lastName: '',
age: 0
}
// lets pretend this function has name, lastName, age, and kids with values
// this function should clear the state but update the kids to value 3. so everything
// empty but the kids field
myFunctionClearState() {
myEmptyObj.kids = 3;
setState(myEmptyObj);
}