背景
我们的 webapp 是使用官方 react-redux 绑定使用 React 和 Redux 编写的。此 Web 应用程序中使用的另一个主要库是PaperJS。我们最近将其转换为 Redux 应用程序,尽管它使用 React 有一段时间了。
问题
有时刷新(通常是每隔一次刷新)会导致
RangeError: Maximum call stack size exceeded
at String.replace (<anonymous>)
at Object.unescape (KeyEscapeUtils.js:49)
at flattenSingleChildIntoContext (flattenChildren.js:32)
at flattenChildren.js:53
at traverseAllChildrenImpl (traverseAllChildren.js:69)
at traverseAllChildrenImpl (traverseAllChildren.js:85)
at traverseAllChildren (traverseAllChildren.js:157)
at flattenChildren (flattenChildren.js:52)
at ReactDOMComponent._reconcilerUpdateChildren (ReactMultiChild.js:209)
at ReactDOMComponent._updateChildren (ReactMultiChild.js:315)
这是失败的 React 源代码:
return ('' + keySubstring).replace(unescapeRegex, function (match) {
return unescaperLookup[match];
});
在上下文中:
/**
* Unescape and unwrap key for human-readable display
*
* @param {string} key to unescape.
* @return {string} the unescaped key.
*/
function unescape(key) {
var unescapeRegex = /(=0|=2)/g;
var unescaperLookup = {
'=0': '=',
'=2': ':'
};
var keySubstring = key[0] === '.' && key[1] === '$' ? key.substring(2) : key.substring(1);
return ('' + keySubstring).replace(unescapeRegex, function (match) {
return unescaperLookup[match];
});
}
这可能表明我在代码中的某个地方滥用了 React,但由于堆栈跟踪不包含对我自己的任何代码的引用,我不确定要查找什么。这似乎是一个无限循环的重新渲染,我怀疑这可能是由于对setState
.
问题
我的怀疑可能吗?鉴于我自己的代码库相当广泛,我该如何进一步诊断这个问题?这在 KeyEscapeUtils 中失败是什么意思?