【发布时间】:2016-05-03 23:20:34
【问题描述】:
问题:
当我最初访问根 URL 时,路由器会呈现正确的页面。导航也可以正常工作。但是,当我点击refresh 时,应用程序崩溃并出现以下错误:
instrument.js:112 Uncaught TypeError: Cannot read property 'length' of undefined
这是instrument.js:112 中的函数。 computedStates 是 undefined。
/**
* Runs the reducer on invalidated actions to get a fresh computation log.
*/
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds) {
// Optimization: exit early and return the same reference
// if we know nothing could have changed.
if (minInvalidatedStateIndex >= computedStates.length && computedStates.length === stagedActionIds.length) {
return computedStates;
}
当我执行localStorage.clear() 并刷新页面时,应用又回来了。
可能导致该问题的软件包:
"react-router": "^2.0.0",
"react-router-redux": "^4.0.0",
"redux-localstorage": "^0.4.0",
使用 react 路由器时处理页面刷新的最佳方式是什么?
【问题讨论】:
标签: reactjs react-router redux