In React I have state variable name1. Is there any difference between. Is there any difference between
this.state.name1 = value;
And
this.setState({name : value});
You will usually set the initial state like this:
this.state = {name1: value}
Then when you need to update it you will use setState
:
this.setState(prevState => ({name1: newValue}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With