i try to use this code:
import React, { Component } from 'react';
export default class Hello extends Component {
static defaultProps = {
somename: "World!"
}
render() {
return (
<h1>Hello {this.props.somename}</h1>
);
}
}
But i then i try to build it in webpack i get syntax error here:
static defaultProps = {
I didn't use jsx and lates ECMAScript standarts before. Can somebody explain me how it must be correctly write.
UPD: my webpack config:
const webpack = require('webpack');
const path = require('path');
const entryPath = path.resolve(__dirname, 'src/client/js');
module.exports = {
mode: 'development',
entry: {
app: entryPath + '/app.js',
main: entryPath + '/main.js',
},
output: {
path: path.resolve(__dirname, 'public/js'),
filename: '[name].js',
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: "babel-loader",
options: {
presets: ["env", "react"]
}
}
]
}
};
.babelrcfile configured?stage-2in your.babelrcconfigbabelrc: falsein options. If the error is still there, kindly post the error too.