Unexpected token < error in react router component

后端 未结 5 1901
小鲜肉
小鲜肉 2020-11-27 15:17

I\'m trying to write router component for my react app. I\'m create new react class and define some routes in componentDidMount method. This is full method

c         


        
5条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 15:43

    do you have this into your package.json ?

    "devDependencies": {
            "@babel/plugin-proposal-class-properties": "^7.7.4",
            "@babel/preset-react": "^7.0.0",
    ...
    }
    

    if yes -> do you have a .babelrc file ? if not :

    add .babelrc file to your root application. and paste it into :

    {
      "presets": ["@babel/preset-env", "@babel/preset-react"]
    }
    

    To finish installation : npm install and npm run dev

    source : https://github.com/babel/babel-loader/issues/789#issuecomment-491554727

提交回复
热议问题