Here is the code where I have included spread operator
style={{ ...styles.detailsRow.icon, alignSelf: 'centre' }}
What things do I need to install or add to make it run?
And also what is its equivalent in es2015
?
The JavaScript spread operator ( ... ) allows us to quickly copy all or part of an existing array or object into another array or object.
In case of arrays,this method does not change the existing arrays but instead returns a new array.
JavaScript ES6 (ECMAScript 6) introduced the spread operator. The syntax is three dots(...) followed by the array (or iterable*). It expands the array into individual elements. So, it can be used to expand the array in a places where zero or more elements are expected.
You need to configure Babel to use the transform-object-rest-spread plugin. Refer to the following link for details: https://babeljs.io/docs/plugins/transform-object-rest-spread/
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