0

consider the following componnet in react:

import React from 'react';

export default class  MainContainner extends React.component{

    render() {
        console.log("I am here");
        return (
            <dev> Salman is here </dev>
        );
    }
}

I have faced with an error in the first line

ERROR in ./js/mainContainner
Module parse failed: C:\Users\Salman\WebstormProjects\hw2\js\mainContainner Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| import React from 'react';
| 
| export default class  MainContainner extends React.component{

I am sure i have the appropriate loader:

  "dependencies": {
    "babel-cli": "^6.5.1",
    "babel-preset-es2015": "^6.5.0",
    "babel-loader": "^6.2.1",
    "babel-preset-react": "^6.3.13",
    "babelify": "^7.2.0"

I have also seen this, and and webpack structure is cool

module.exports={

    entry: './js/main.js',
    output:{

        filename: 'bundle.js'
    },
    module: {
        loaders: [
            {
                test: /.js?$/,
                loader: 'babel-loader',
                exclude: /node_modules/,
                query: {
                    presets: ['es2015', 'react']
                }
            }
        ]
    },
    devServer:{


        port:3000
    }

};

what is the problem?

Community
  • 1
  • 1
Jeff
  • 7,767
  • 28
  • 85
  • 138

0 Answers0