Home > Back-end >  While empty the Cart , Error: Rendered fewer hooks than expected. This may be caused by an accidenta
While empty the Cart , Error: Rendered fewer hooks than expected. This may be caused by an accidenta

Time:04-07

Code Uploaded

when I am deleting Item from cart that error appearing from here

CodePudding user response:

One of the rules of react is never call react hooks inside child functions or don't call them conditionally.

You have to call them at the top inside a parent component's scope.

CodePudding user response:

The error you are getting is because of useEffect present in Totals child function.

Either remove useEffect from Totals child function and implement its logic in parent function Cart or make Totals a separate component and use that component in Cart.

  • Related