TypeError when using React: Cannot read property 'firstChild' of undefined

后端 未结 6 1194
误落风尘
误落风尘 2020-12-29 03:22

Sometimes, when using React libraries, such as react-router, I get this error:

Uncaught TypeError: Cannot read property \'firstChild\' of undefined

6条回答
  •  执念已碎
    2020-12-29 04:04

    Using require('react') and require('React') inconsistently causes this problem as well, even if you only have one version of React.

    https://www.npmjs.com/package/gulp-browserify didn't have this problem. Once I stopped using gulp-browserify and switched to watchify+browserify, Uncaught TypeError: Cannot read property 'firstChild' of undefined started happening.

提交回复
热议问题