3

Ok, I get it. A useEffect is calling a setState that triggers the same useEffect again, creating an infinite loop.

My question is: What is the best way to debug this situation? Is there a way to track which specific properties or state variables were the ones that triggered a useEffect callback?

Jose Ospina
  • 2,097
  • 3
  • 26
  • 40
  • Please add a code example. You could start removing items from the dependency array so the use effect wouldn't be called again. – Colin Hale Jun 24 '22 at 19:09
  • This answer is very helpful in this context https://stackoverflow.com/questions/55187563/determine-which-dependency-array-variable-caused-useeffect-hook-to-fire#answer-59843241 – Moath Jun 24 '22 at 19:18
  • Thanks. That question and answer are indeed what I was looking for. I have voted to mark this question as duplicate of that one – Jose Ospina Jun 24 '22 at 20:07

0 Answers0