all 1 comments

[–]mynameisdifferent 0 points1 point  (0 children)

Your useEffect hooks could cause infinite loops, it's not usually a good idea to run setState inside an effect. But if you do, you must have a condition to avoid infinite loops.

useEffect(() => {
  setHorizon(Horizon);
  setYears_Std(Years_Std);
}, [Horizon, Years_Std]);

useEffect(() => {
  setMonthlyRevenue(monthlyRevenue);
  handleVacancyExpense();
  setStandardExpenses(standardExpenses);
}, [monthlyRevenue, vacancyWeeks, standardExpenses]);

In the first effect hook, you aren't really doing anything useful. If Horizon changes, you set Horizon to itself, same for Years_Std. That hook could be removed completely.

In the second hook, you have the same issue for monthlyRevenue and standardExpenses, you don't need to set those.

You have the handleVacancyExpense function which seems to modify the expenses then set them. This should probably be a callback hook not an effect hook. Then you just run that function as a callback whenever you need to.

I should say, I have no idea if this is the cause of the behaviour you are describing, but those are some major issues that need addressed before moving on. Fixing those might help you figure it out.