Ladislav M
Ladislav M

Reputation: 2187

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().

Upvotes: 4

Views: 5794

Answers (2)

Fomahaut
Fomahaut

Reputation: 1212

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,) { }

Upvotes: 6

Mr Speaker
Mr Speaker

Reputation: 3107

React Native is using the Babel transpiler - the features it enables are all of Babel Core, plus whatever is whitelisted in /packager/transformer.js.

Upvotes: 1

Related Questions