Error: Missing class properties transform
Test.js:
export default class Home extends React.Component {
static defaultProps = {
color: 'blue',
text: 'Confirm'
};
}
.babelrc:
{
"presets": ["latest", "react"],
"plugins": ["transform-class-properties"]
}
的package.json:
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-latest": "^6.24.1",
"babel-preset-react": "^6.24.1",
我不知道是否应该要求其他模块
答案 0 :(得分:0)
我明白了。该网站可以帮助您测试代码并添加预设。The compiler for JavaScript
的package.json
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-env": "^1.4.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1"
}
.babelrc
{
"presets": [
"env",
"react",
"stage-0"
]
}
webpack.config.js
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
}
]
}