React中出现“Maximum update depth exceeded”错误而没有意外递归,这是否合理?

huangapple go评论80阅读模式
英文:

Is it reasonable to get a React "Maximum update depth exceeded" without accidental recursion?

问题

我正在编写一个带有大约12,000个可点击的动画点的Cesium/Resium应用程序。
我收到了React警告“最大更新深度超过”。
当点数小于5000个时,没有警告,但在7,000到8,000范围内,我经常看到这个警告。
在浏览器中进行调试时,我的调用堆栈中有大量的“recursivelyTraverseMutationEffects”,然后是大量的“postMessage(async)”。

我已经消除了两个导致这个警告的原因,它们是愚蠢的递归。我有一个useEffect,它正在更新它的触发器。

这个警告是应用程序需要优化的标志,还是表示发生了一些愚蠢的递归渲染的标志?

英文:

I'm writing a Cesium/Resium app with ~12000 clickable, animated points.
I'm getting the React warning Maximum update depth exceeded.
When there are <5000 points, there's no warning, but somewhere in the 7-8000 range, I tend to see this warning.
When debugging in the browser, my call stack is a lot of recursivelyTraverseMutationEffects followed by a lot of postMessage (async)

I already eliminated 2 sources of that warning that were silly recursion. I had a useEffectthat was updating its trigger.

Is this warning a sign the app needs to be optimized or a sign that there's some silly recursive rendering happening?

答案1

得分: 0

这是一个错误,你需要修复它。

根据完整的错误信息,这个错误意味着

  • 至少有不必要的工作,导致你的应用非常慢,或者
  • React 将停止在这个错误出现时的工作,因此你的应用可能会出现故障或内容丢失。
英文:

This is an error, you need to fix it.

Depending on the full error message, this error means

  • at least that there is unnecessary work done, making your app very slow, or
  • React will stop its work at this error, so your app will likely be broken or have content missing.

答案2

得分: 0

是的。
在没有意外递归的情况下获得React的“最大更新深度超出”是合理的。
我们将实体的渲染尺寸设置得非常小,现在在触发“最大更新深度超出”警告之前,我们可以显示更多实体。
Cesium/Resium在我们的应用程序在浏览器中执行其他操作时难以渲染这么多像素。
堆栈变得太高是因为我们要求太多,而不是因为我们导致了不良的更新循环。

英文:

Yes.
It is reasonable to get a React "Maximum update depth exceeded" without accidental recursion.
We set the render size to the entities to teeny tiny, and now we can display way more entities before hitting the Maximum update depth exceeded warning.
Cesium/Resium struggles to render so many pixels while our app is doing other things in the browser.
The stack ends up too tall because we're asking for too much, and not because we're causing a bad update loop.

huangapple
  • 本文由 发表于 2023年6月22日 04:59:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76527097.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定