React - Minified exception occurred

≡放荡痞女 提交于 2019-11-28 08:54:21

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

set NODE_ENV=development

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')
        }
    })
]

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

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)

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")

Have you check the DOM element that you are trying render ? I had this error before due to a silly mistake. The worst part is bundle was minified. The element id is not same

Index.html


 <div id="ds-app"></div>

app.jsx


React.DOM.render(<App/>, document.getElementById('app'))

As of version 15.2, production React error messages (NODE_ENV=production) now include a URL that you can visit where you can see the original, unobfuscated error.

https://twitter.com/dan_abramov/status/748969886433546240

You should consider upgrading to React 15.2 in order to get access to these error messages. Additionally, some production crash reporting tools automatically unminify these errors for you.

Vithu Jey

use the min.js files in production or bundle your application code with process.env.NODE_ENV === 'production' and you should be good to go!

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'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!