React - Minified exception occurred

前端 未结 10 1417
离开以前
离开以前 2020-12-09 07:54

I have React js installed via NPM and using browserify to manage components in react. When an exception occurs in React, the console shows as

\"Uncau

相关标签:
10条回答
  • 2020-12-09 08:02

    I FINALLY SOLVED THIS.

    If you're like me and ran that command to set NODE_ENV and it's literally never worked, check if you're linking to react.min.js instead of the full versions of the files.

    Link to the full versions and it should work like a charm. :D

    0 讨论(0)
  • 2020-12-09 08:05

    Setting NODE_ENV to development as Benjamin Gruenbaum pointed out in the comment resolved the issues.

    set NODE_ENV=development
    
    0 讨论(0)
  • 2020-12-09 08:09

    If you are encountering this issue with Karma + Webpack, the following Webpack configuration fixed the issue for me when running tests:

    plugins: [
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify('development')
            }
        })
    ]
    
    0 讨论(0)
  • 2020-12-09 08:10

    I had this issue, and for me I didn't need to disable minification or use react source. My script was just loading before the root element. So I just moved the script out of the head and below the div in the index file source code and that fixed it.

    Changed my index.jade from this:

    html
     head
       title Super coo site
       script(src="bundle.js")
     body
       div#root
    

    To this:

    html
     head
       title Super coo site
     body
       div#root
       script(src="bundle.js")
    
    0 讨论(0)
  • 2020-12-09 08:13

    If you are using jspm to bundle your code, note that version 0.16.24 imports the minified "production" version of React, which throws this error. My temporary solution was to downgrade jspm to 0.16.23.

    edit Future versions of jspm will allow you to declare production vs. development versions (see jspm beta documentation)

    0 讨论(0)
  • 2020-12-09 08:16

    I got this error when my render method returned undefined eg

    render() {
        let view;
        // Not paying attention and slip a case where view won't get assigned a value
        if(this.props.foo == 'hello') {
            view = <HelloView />
        }
        else if(this.props.foo == 'bye') {
            view = <ByeView />
        }
        return view;
    }
    

    This will trigger the error when this.props.foo is 'hi'

    0 讨论(0)
提交回复
热议问题