Why is it possible to use destructuring assignment in React Native?

In the example edit your own tutorial , I find the syntax that is defined in the ECMAScript 2015 (ES6) standard called Destructuring. But as I know, iojs and nodejs do not support this syntax. How can I use it in React Native?


source to share

1 answer

You are correct nodejs and iojs doesn't support ES6 syntax. But react in your native language:

Since version 0.5.0, React Native ships with the Babel JavaScript compiler.

More details here

This means that there is another transpiler ( Babel ) to work in the React package. It converts from ECMAScript 2015 (ES6) to ES5. This allows for ES6 features like: destructuring, computed property keys, classes, arrow functions, block-range variables, etc.

If you want to use these features in a React (not Native) app, you will need to include Babel in your project.


There is no other transpiler.

React and React Native switched their respective build systems to use Babel . This replaced JSTransform , a source transform tool that we wrote on Facebook.

More in Legacy JSTransforms and React Tools



All Articles