javascript - How to understand this syntax? var {...} = React; -


this question has answer here:

in react native example: https://github.com/facebook/react-native

var react = require('react-native'); var { scrollview, touchablehighlight, text } = react;  var touchdemo = react.createclass({   render: function() {     return (       <scrollview>         <touchablehighlight onpress={() => console.log('pressed')}>           <text>proper touch handling</text>         </touchablehighlight>       </scrollview>     );   }, }); 

what syntax mean?

var { scrollview, touchablehighlight, text } = react; 

i typed in nodejs console cause syntax error. special javascripts syntax react native?

thanks

that destructuring, ecmascript 6 feature. far know not included in version of node.js or iojs yet, there may command line flag can use enable it.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -