我将我的 React 版本从 0.12.2 升级到 0.13.2,我的 React-Router 从 0.12.4 升级到 0.13.2。只进行这两个升级而不做其他任何事情,现在当我加载我的网页/应用程序时出现以下错误:
Uncaught TypeError: Cannot read property '_currentElement' of null
任何想法可能导致这种情况?我似乎对潜在的 React-Router 错误有一些参考,但没有确定性。
导致错误的具体行是:
ReactRef.detachRefs(internalInstance, internalInstance._currentElement);
更新 1:我也刚刚根据@BinaryMuse 的评论将 reactify 从 1.0.0 版升级到 1.1.0 并将 react-router-bootstrap(我还没有实际使用)从 0.9.1 升级到 0.13.0 - 没有变化。
更新 2:经过进一步测试,我将其范围缩小到react-d3的问题。从我的站点禁用 react-d3 代码会导致错误消失。我正在删除路由代码以使帖子更简洁,因为我现在相当确信 react-router 不会导致此问题。
更新 3:感谢 @CoryDanielson 为react-d3创建新标签。
包.json
{
"author": "me",
"name": "my project",
"description": "my awesome project",
"version": "0.1.0",
"dependencies": {
"bootstrap": "^3.3.2",
"d3": "^3.5.5",
"font-awesome": "^4.3.0",
"jquery": "^2.1.3",
"react": "^0.13.2",
"react-bootstrap": "^0.21.0",
"react-d3": "^0.3.1",
"react-router": "^0.13.2",
"react-router-bootstrap": "~0.13.0",
"reflux": "^0.2.6",
"uuid": "^2.0.1"
},
"devDependencies": {
"browser-sync": "^2.2.2",
"browserify": "^9.0.3",
"del": "^1.1.1",
"envify": "^3.4.0",
"gulp": "^3.8.11",
"gulp-css-url-adjuster": "^0.2.3",
"gulp-jshint": "^1.9.2",
"gulp-minify-css": "^0.5.1",
"gulp-sourcemaps": "^1.5.0",
"gulp-uglify": "^1.1.0",
"gulp-util": "^3.0.4",
"gulp-watch": "^4.1.1",
"reactify": "~1.1.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.0.0",
"watchify": "^2.4.0"
},
"browserify": {
"transform": [
[
"reactify",
{
"es6": false
}
]
]
},
}