Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ES6 features in React Native

Where could I find the list of ES6 features taht are ready to use in React Native?

Eg Object.assign().

like image 634
Ladislav M Avatar asked Mar 16 '23 02:03

Ladislav M


1 Answers

It's depends on what JSX done (see this table). You can use Babel for more ES6 feature, this post maybe helps.

[EDIT] According this official doc, full support table is here:

ES5

// Reserved Words: 
promise.catch(function() { }); 

ES6

// Arrow function: 
<C onPress={() => this.setState({pressed: true})}

// Call spread: 
Math.max(...array);

// Class: 
class C extends React.Component { render() { return <View />; }

// Destructuring: 
var {isActive, style} = this.props;

// Iteration: 
for (var element of array) { }

// Computed Properties: 
var key = 'abc'; var obj = {[key]: 10};

// Object Consise Method: 
var obj = { method() { return 10; } };

// Object Short Notation: 
var name = 'vjeux'; var obj = { name };

// Rest Params: 
function(type, ...args) { }

// Template: 
var who = 'world'; var str = `Hello ${who}`;

ES7

// Object Spread: 
var extended = { ...obj, a: 10 };

// Function Trailing Comma: 
function f(a, b, c,) { }
like image 120
Fomahaut Avatar answered Mar 26 '23 02:03

Fomahaut