Categories
React Answers

How to fix the ‘Trace: The node type SpreadProperty has been renamed to SpreadElement at Object.isSpreadProperty’ error with React?

Spread the love

To fix the ‘Trace: The node type SpreadProperty has been renamed to SpreadElement at Object.isSpreadProperty’ error with React,. we add the "@babel/plugin-proposal-object-rest-spread" plugin.

We install it with

npm i @babel/plugin-proposal-object-rest-spread --save-dev

Then we add

{
  "presets": ["@babel/preset-env", "@babel/preset-react"],
  "plugins": ["@babel/plugin-proposal-object-rest-spread"]
}

into .babelrc to add the "@babel/plugin-proposal-object-rest-spread" plugin.

Then in webpack.config.js we add

{
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        loaders: "babel-loader",
      },
    ];
  }
}

to load .js and .jsx files with babel-loader.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *