How could this statement assigns?
var { AppRegistry, View, StyleSheet, ListView } = React;
How could this statement assigns?
var { AppRegistry, View, StyleSheet, ListView } = React;
This is destructuring assignment that is coming in ECMAScript 6.
var s = { a: 1, b: 2 }
var { a, b } = s;
will assign 1
to a
and 2
to b
.
Presumably, React
is an object that has properties AppRegistry
, View
etc., and their values are being assigned to variables with the same name.
This syntax is, at the moment of this answer, not yet widely available.
This is a new feature in ES6 as Amadan said. ES6 will be released soon and all modern browsers will support it eventually. A lot of projects use Babel together with webpack to compile code to ES5 synatax so that it can be used on any browsers.
React native have their own transforms which support part of ES6:
https://facebook.github.io/react-native/docs/javascript-environment.html#content
So you don't need Babel and webpack if you are using their packager. In the future version facebook may use Babel as well.