I'm watching the Redux videos found here: http://redux.js.org/ and I'm seeing the following pattern:
const { Component } = React;
How does this work?
I'm watching the Redux videos found here: http://redux.js.org/ and I'm seeing the following pattern:
const { Component } = React;
How does this work?
This is called Object Destructuring. The result of the above statement is that a variable called Component
now exists. NOTE: If you're familiar with Python it's a lot like tuple-unpacking.
var foo = {a: 1, b: 2};
var {a, b} = foo;
var bar = {c: 3, d: 4};
var {c} = bar;
console.log(a) => 1
console.log(b) => 2
console.log(c) => 3