question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The return of "Error: Maximum update depth exceeded."

See original GitHub issue

Perhaps 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.

  1. Go to https://codesandbox.io/s/strange-lalande-91wgp
  2. Click “Set bad crop data” in rendered view
  3. Error: Maximum update depth exceeded should be thrown

Example of reproduction: maximum-update-bug

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:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
DominicTobias-b1commented, Apr 8, 2020

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

2reactions
DominicTobiascommented, Apr 8, 2020

Thanks @jamsinclair for the clear reproducible scenario, please try 8.6.2

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found