What is the difference between these two lines of code?
let { fadeAnim } = this.state;
vs
let fadeAnim = this.state;?
What is the difference between these two lines of code?
let { fadeAnim } = this.state;
vs
let fadeAnim = this.state;?
If this.state
is a reference to an object, then
let { fadeAnim } = this.state;
is like
let fadeAnim = this.state.fadeAnim;
It's a destructuring assignment that implicitly extracts one or more properties from an object (just one in this case).
let { fadeAnim } = this.state;
Equals
let fadeAnim = this.state.fadeAnim;
It’s called destructuring assignment: https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Operatoren/Destructuring_assignment