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
.