1

I have class UsersContainer and Arrow function in it. But project does not compile because of "Unexpected token =" in arrow function.

Please help!

webpack.config.js

let webpack = require('webpack');

module.exports = {
    entry: "./client/client.js",
    output: {
        path: __dirname + "/public/build",
        publicPath: "build/",
        filename: "bundle.js"
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                loader: "babel-loader",
                exclude: [/node_modules/, /public/]
            },
            {
                test: /\.json$/,
                loader: "json-loader"
            }
        ]
    }
};

UsersContainer

class UsersContainer extends React.Component{
    componentDidMount() {
        //this works
    };

    onChangeSomething = (parameter) => {
        //this does not work, because = is unexpected token
    };

    render(){
        return <Users />
    }
}
Tony Ngo
  • 19,166
  • 4
  • 38
  • 60
  • 1
    https://stackoverflow.com/questions/48801984/unexpected-token-in-react-component check this link ,it may help – Kishan Jaiswal Oct 10 '19 at 09:12
  • the problem is not with the arrow function. doesn't your code have any problems if you remove that arrow function and its usages? – Omid Ziyaee Oct 10 '19 at 09:13
  • @OmidZiyaee Yes, it works if I remove this function. Kishan Jaiswal just helped me. Thank you for responding! –  Oct 10 '19 at 09:17
  • I'm just curious. Doesn't Babel identify a missing plugin and print it in the error message? Something like "install class properties plugin"? – maazadeeb Oct 10 '19 at 15:13
  • @MaazSyedAdeeb it seems not in my case) –  Oct 11 '19 at 04:53

0 Answers0