Uncaught TypeError: React.createClass is not a function

0

I have the code with emac6 so I do not understand why the next error in the browser when launching the app with the code already compiled bundle.js .

Uncaught TypeError: React.createClass is not a function

webpack.config.js

/* eslint no-unused-vars: 0 */

const webpack = require('webpack'),
    path = require('path'),
    ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
    entry: './src/index.js',
    devtool: 'source-map',
    plugins: [
        new ExtractTextPlugin('style.css'), 
    ],
    output: {
        path: path.join(__dirname, 'dist'),
        publicPath: '/',
        filename: 'bundle.js'
    },
    devServer: {
        inline: true,
        port: 3333,
        contentBase: 'public'
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: ['babel-loader'],
                query: {
                    presets: ['es2015', 'react']
                }
            },
            {
                test: /\.scss$|\.css$/,
                //exclude: /node_modules/, 
                loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader?root=.')
            },
            {
                test: /\.(eot|png|jpg|jpeg|gif|woff|woff2|svg|ttf)$/,
                exclude: /node_modules/,
                loader: 'url-loader?limit=10000'
            }
        ]
    }
};

package.js

    "dependencies": {
    "axios": "0.15.3",
    "chai": "3.5.0",
    "colors": "1.1.2",
    "immutable": "3.8.1",
    "lodash": "4.17.2",
    "moment": "2.17.1",
    "navigo": "3.5.0",
    "node-sass": "4.5.0",
    "prop-types": "^15.6.0",
    "react": "15.3.2",
    "react-addons-css-transition-group": "15.4.1",
    "react-dom": "15.3.2",
    "react-mdl": "1.9.0",
    "react-mdl-extra": "1.4.3",
    "react-notify": "2.0.1",
    "react-redux": "4.4.6",
    "react-toastr": "2.8.2",
    "redux": "3.6.0",
    "redux-thunk": "2.1.0",
    "jsonwebtoken": "7.4.2"

  },
  "devDependencies": {
    "babel-cli": "6.10.1",
    "babel-core": "6.10.4",
    "babel-loader": "6.2.4",
    "babel-preset-es2015": "6.9.0",
    "babel-preset-react": "6.11.1",
    "babel-register": "6.11.5",
    "css-loader": "0.23.1",
    "eslint": "3.0.1",
    "eslint-plugin-import": "1.10.2",
    "eslint-plugin-react": "5.2.2",
    "eslint-watch": "2.1.13",
    "extract-text-webpack-plugin": "1.0.1",
    "file-loader": "0.9.0",
    "isparta": "4.0.0",
    "istanbul": "0.4.4",
    "jsx-loader": "0.13.2",
    "jwt-decode": "2.2.0",
    "mocha": "2.5.3",
    "npm-run-all": "2.3.0",
    "sass-loader": "4.1.1",
    "style-loader": "0.13.2",
    "url-loader": "0.5.7",
    "webpack": "1.13.1",
    "webpack-dev-server": "1.15.0",
    "webpack-hot-middleware": "2.13.2"
  }
    
asked by wootsbot 08.11.2017 в 19:45
source

1 answer

1

Most likely, you're forgetting to include the reactive object in your components.

Wherever you use components, include:

import React from 'react';

The rationale for this is that although you can create components of the type:

const MiComponente = function (props) {
 return (...);
};

Even if you are not using the React object, when webpack transpile it will convert it to code of the type:

React.createClas .... 

That's why you need to include the React object.

Check your components, some will need that import.

    
answered by 12.11.2017 в 20:53