Spread Attributes

ECMAScript 2015 - Spread Attributes

Posted by Kuo on February 18, 2018

… are called Spread Attributes which the name represents it allows an expression to be expanded.

var parts = ['two', 'three'];
var numbers = ['one', ...parts, 'four', 'five'];  // ["one", "two", "three", "four", "five"]

Another example

//just assume we have an object like this:
var person= {
    name: 'Alex',
    age: 35 
}
<Modal {...person} title='Modal heading' animation={false} />

is equal to

<Modal name={person.name} age={person.age} title='Modal heading' animation={false} />