Source:  Twitter logo

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?

You need to configure Babel to use the transform-object-rest-spread plugin. Refer to the following link for details:

24 users liked answer #0dislike answer #024
const314 profile pic

You are missing one babel preset, stage-0

npm install --save-dev babel-preset-stage-0

if you have .bablerc file add following to it.

    "es2015", "react", "stage-0"

Or added to webpack config in loader.

14 users liked answer #1dislike answer #114
James Norman profile pic
James Norman

I had the same problem, and the fix I found was to add experimentalObjectRestSpread to the ecmaFeatures setting in .eslintrc:

"parserOptions": {
  "ecmaVersion": 6,
  "sourceType": "module",
  "ecmaFeatures": {
     "jsx": true,
     "experimentalObjectRestSpread": true
8 users liked answer #2dislike answer #28
astoria boy profile pic
astoria boy

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).