Variable declaration in reactjs documentation [dup

2019-09-03 18:40发布

问题:

This question already has an answer here:

  • Javascript object bracket notation ({ Navigation } =) on left side of assign 4 answers

react.js documentation has following variable declarations:

var { Image, StyleSheet, Text, View } = React;

Could you tell what does it meant? Thank you.

回答1:

This is the destructuring syntax, which is part of ES6.



回答2:

It's a feature of ES6 called destructuring. Essentially the same as writing:

var Image = React.Image;
var StyleSheet = React.StyleSheet;
var Text = React.Text;
var View = React.View;