Can you write
let firstNameValid = this.state.firstNameValid;
firstNameValid = value.length >= 1;
this.setState({ firstNameValid, firstNameValid,})
as short form syntax
this.setState({ firstNameValid})
I have tried the above code, it seems to work fine. Just wonder if it will have any side effect?
this.setState({ firstNameValid })
is just sugar for this.setState({ firstNameValid: firstNameValid })
. No side effects.
These are called shorthand property names
, and you can read more about them here.
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