mirror of
https://github.com/facebook/react.git
synced 2026-02-24 04:33:04 +00:00
* Limit the number of nested synchronous updates In Stack, an infinite update loop would result in a stack overflow. This gives the same behavior to Fiber. Conceptually, I think this check belongs in findNextUnitOfWork, since that is what we call right before starting a new stack. I've put it in scheduleUpdate for now so I have access to the component that triggered the nested update. But we could track that explicitly instead. I've chosen 1000 as the limit rather arbitrarily. Most legit use cases should really have a much smaller limit, but a smaller limit could break existing code. For now I'm only concerned with preventing an infinite loop. We could add a warning that fires at the smaller limit. * Move check to findNextUnitOfWork Including the name of the component in the message probably isn't necessary. The JS stack will include either componentDidUpdate or componentWillUpdate. And the component that's updating won't necessarily be the component whose lifecycle triggered it. So let's move the infinite loop check to findNextUnitWork as I originally wanted to.