【问题标题】:Minified React error #130 when building react module构建反应模块时缩小反应错误#130
【发布时间】:2019-11-11 17:07:53
【问题描述】:

我来了

缩小的 React 错误 #130

当我将我的反应模块导入另一个应用程序时,模块构建可能很奇怪或不正确。

我引用了一个类似的问题。

Uncaught Error: Minified React error #130

但我认为我的设置正确。

src/Fetch

import React, {Component} from 'react';
import MyFetch from './MyFetch';
const Fetch = (props) => (
     <div>
       <form onSubmit={props.onSubmit}>
            <input type="text" value={props.url} placeholder="enter a url" onChange={props.onChange}/>
        </form>
          <MyFetch url={props.url} method={props.method}/>
     </div>
)
export default Fetch;

src/index.js

import Fetch from './Fetch';

export default Fetch

dist/index.js

import React from 'react';
import { render} from 'react-dom';
import Fetch from '../src'
const App = () => (
    <Fetch />
);
render(<App />, document.getElementById("root"));

webpack.config.js

const path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const htmlWebpackPlugin = new HtmlWebpackPlugin({
    template: path.join(__dirname, "dist/index.html"),
    filename: "./index.html"
});
module.exports = {
    entry: path.join(__dirname, "dist/index.js"),
    output: {
      path: path.join(__dirname, './'),
      filename: 'index.js',
   },
    module: {
        rules: [
          {
            test: /\.js$/,

            exclude: /(node_modules|bower_components|build)/,
            use: {
              loader: 'babel-loader',
              options: { 
                presets: ['@babel/preset-env', '@babel/react'],
                plugins:['@babel/plugin-proposal-class-properties']
              }
            }
          }
        ]
      },
    plugins: [htmlWebpackPlugin],
    resolve: {
        extensions: [".js", ".jsx"]
    },
    devServer: {
        port: 3001
    }
};

【问题讨论】:

    标签: reactjs


    【解决方案1】:

    修好了

    plugins: [htmlWebpackPlugin,new webpack.DefinePlugin({
          'process.env': {
              NODE_ENV: JSON.stringify('development')
          }
      })]
    

    React - Minified exception occurred

    【讨论】:

      猜你喜欢
      • 2018-10-29
      • 2020-10-03
      • 1970-01-01
      • 1970-01-01
      • 2018-11-27
      • 1970-01-01
      • 1970-01-01
      • 2018-10-05
      • 2019-01-13
      相关资源
      最近更新 更多