5

I'm working on a project in which if I directly hit a PLP url like http://localhost:3000/categories/dog/food/dry-food, than it gives a react error of below screenshot.

A rendering error occurred: Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.. Maximum Update Depth Exceeded

In this, there is no widget object being passed to payload

Upon searching on this, I came to know that this might be an issue where due to continuous calls, next stops a might be stopped after a threshold. I also saw a series of __nextjs-original-stack-frame errors on network tab which I was unable to debug from which component it might be causing the issue. Can anyone help me on this on below pointers?

  1. How do I debug this? From where this is being called as I cannot see a proper file in the initiator section on network tab on the Inspect Tools.
  2. How to get rid of this?

enter image description here

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've tried various ways like reducing the GraphQL children from 100 to 20. Tried removing unwanted useEffect code but still if I open the targeted URL in Incognito for the first time, it will throw the error. One thing to note is, once error is rendered, upon refreshing it will be resolved.

For it to reproduce, I will need to close the whole incognito browser and that again hit the targeted URL.

2
  • You would need to share your component code to see what the issue might be
    – Richard Seal
    Commented Sep 25 at 18:34
  • 1
    Does this happen only on local / debug builds? In my experience, errors like this often come about because of useEffect hook dependencies which cause infinite update loops. Recommendation is to comment out sections of the code until you find the source. Also try clearing the Next cache and restarting the app. Commented Sep 25 at 19:41

1 Answer 1

0

I have solved this issue by adding productionBrowserSourceMaps: true flag in the next.config.mjs file. Your file will look like this -

const nextConfig = {
  // ...otherDetails 
  productionBrowserSourceMaps: true,
};

export default nextConfig;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.