1

How many times does a React component need to update state before the maximum update depth is exceeded and the error is thrown?

I understand it's meant to prevent infinite loops or unnecessary state updates. I've run into an instance in which I need to chunk my calls to state to avoid this error and, when determining chunk size, it would be helpful to know how many state updates are allowed, before the error is thrown.

twils0
  • 2,431
  • 2
  • 12
  • 24
  • Possible duplicate of [ReactJS: Maximum update depth exceeded error](https://stackoverflow.com/questions/48497358/reactjs-maximum-update-depth-exceeded-error) – Andy Ray Oct 09 '18 at 18:43
  • @AndyRay It’s not a duplicate. I’m asking for the number of updates before the error is thrown. I’m not asking for help solving the error. – twils0 Oct 09 '18 at 19:16
  • 1
    According to [the source code](https://github.com/facebook/react/blob/d83601080a7c913cedcfbad86044702d008039c7/packages/react-reconciler/src/ReactFiberScheduler.js#L1815-L1816) it looks like 50 – Hamms Oct 09 '18 at 19:48

1 Answers1

3

In React 15, maximum update depth was determined by call stack size limit and was specific to particular JS engine.

In React 16, maximum update depth originally was 1000. It was decreased to 50 in React 16.5.0.

Estus Flask
  • 206,104
  • 70
  • 425
  • 565