The return of "Error: Maximum update depth exceeded."
See original GitHub issuePerhaps related to #218
When using percentageCrop
and adjusting the crop selection in certain circumstances this error is thrown:
Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
I have created a variant of your hooks demo in which you can usually replicate this bug.
Reproduction Steps (Updated.
- Go to https://codesandbox.io/s/strange-lalande-91wgp
- Click “Set bad crop data” in rendered view
- Error: Maximum update depth exceeded should be thrown
Example of reproduction:
If I get a spare moment, I’ll see if I can help debug further for you!
Edit: I’ve updated the example with buggy crop data that should trigger an infinite loop on update.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
ReactJS: Maximum update depth exceeded error
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate.
Read more >Fix the "Maximum Update Depth Exceeded" Error in React
React is an excellent framework, but it can have some tricky “gotchas.” One of which is when you accidentally cause an infinite render...
Read more >Maximum update depth exceeded. This can happen when a ...
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate.
Read more >Maximum update depth exceeded problem without using ...
"Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have ...
Read more >How to solve "error: maximum update depth exceeded." error?
I am getting this below error > Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey thanks I was worried about this since I added “completing aspect crops” on componentDidUpdate. The idea was the make it easier to make a percentage aspect crop without having to do some maths yourself.
// isAspectCropInvalid https://github.com/DominicTobias/react-image-crop/blob/master/lib/ReactCrop.js#L126
// componentDidUpdate https://github.com/DominicTobias/react-image-crop/blob/master/lib/ReactCrop.js#L285
The problem is probably that the library thinks that the aspect crop is invalid over and over again and keeps trying to correct it due to imprecision when converting percentage to pixels. What browser and version is that by the way?
I will take a look in the next day or 2
Thanks @jamsinclair for the clear reproducible scenario, please try 8.6.2