In my set state I am passing an object with key values pairs.
I have three scenarios when user can pass a new object to the state.
How can I delete previous entries and pass new ones?
Here I am passing a state object from Child component to parent
<Car passInputs={this.getInputs}/>
This is how I get it in Parent component and pass it to the state
getInputs = (data) => {
this.setState({ input: { ...this.state.input, ...data} }, () =>
{console.log(this.state.input)});
}
My problem is that I conditionally pass 3 different objects and if I have passed first object conditionally then I need to delete it if I pass the second one and If I pass the third one I need to delete the second one.
The sequence doesn't matter.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…