I would love to use Javascript ES6 and ES7 syntax (especially async/await, my new best friends) without transpiling. Is that even an option? And should it be an option?
It all depends on the sub-question: what Javascript engine does react-native effectively use, on Android and iOS? Is it taken from the device itself? (in which case transpiling IS the only option...) Or is it provided by React Native?
Array Includes Prior to ES7, the indexof() method of the Array class could be used to verify if a value exists in an array . The indexof() returns the index of the first occurrence of element in the array if the data is found ,else returns -1 if the data doesn't exist.
React Native uses Babel, the JavaScript compiler, to transform our JavaScript and JSX code. One of Babel's features is its ability to compile ES6 syntax into ES5-compliant JavaScript, so we can use ES6 syntax throughout our React codebase.
Babel is a free and open-source JavaScript transcompiler that is mainly used to convert ECMAScript 2015+ (ES6+) code into a backwards compatible version of JavaScript that can be run by older JavaScript engines. Babel is a popular tool for using the newest features of the JavaScript programming language.
You can happily use async
/await
in React Native (you've been able to for awhile, in fact... since 0.10). As to using it without transpiling, that's a slightly stickier question. React Native requires only Node v6 and above, so obviously there's a fair bit of transpiling done via Webpack/Babel in order to ensure it still works with older versions of Node.
The deployed environment on the device is JavaScriptCore (see JavaScript Environment for more details). While you're debugging, you're using V8 via Chrome.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With