Skip to content

Comments

Fix useEffect deps causing toast spam on EarnPage#1082

Closed
kunal-595 wants to merge 1 commit intojoinmarket-webui:v2from
kunal-595:fix/earnpage-effect-deps
Closed

Fix useEffect deps causing toast spam on EarnPage#1082
kunal-595 wants to merge 1 commit intojoinmarket-webui:v2from
kunal-595:fix/earnpage-effect-deps

Conversation

@kunal-595
Copy link
Contributor

The start/stop mutation objects are new refrences on each render, causing both effects to run repetedly, narrowed dependencies to isSuccess and reset, which are the only values used, to prevent repeated toasts and resets

Copilot AI review requested due to automatic review settings February 16, 2026 01:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where toast notifications were being displayed repeatedly on the EarnPage due to incorrect useEffect dependency arrays. The mutation objects returned by React Query's useMutation are new references on each render, causing effects to run continuously. The fix narrows the dependencies to only include the specific properties that matter: isSuccess for detecting successful mutations and reset for cleanup.

Changes:

  • Replaced entire startMaker mutation object in useEffect deps with specific properties startMaker.isSuccess and startMaker.reset
  • Replaced entire stopMaker mutation object in useEffect deps with specific properties stopMaker.isSuccess and stopMaker.reset
  • Added eslint-disable comments to suppress warnings about stable function dependencies (toast, scrollToTop)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@theborakompanioni
Copy link
Collaborator

I guess this was introduced in a recent PR when the isWaitingMakerStart was moved from the useMutation hook, right? Can we revert to the old approach? What do you think?

@theborakompanioni
Copy link
Collaborator

I am not experiencing this behaviour - it is currently not optimal, but I do not see what this fixes. Can you elaborate?

@kunal-595
Copy link
Contributor Author

thanks for checking after re-testing on latest v2, I do not see any user visible impact. The change was mainly to tighten the effect dependencies ,if reverting to the previous isWaitingMakerStart approach is preferred for consistency, i am happy to switch.

@theborakompanioni
Copy link
Collaborator

thanks for checking after re-testing on latest v2, I do not see any user visible impact. The change was mainly to tighten the effect dependencies ,if reverting to the previous isWaitingMakerStart approach is preferred for consistency, i am happy to switch.

I have a small refactor regarding this and will push it soon, okay for you?

@theborakompanioni
Copy link
Collaborator

Closing this in favour of #1144 - please reopen if you think this is a mistake or if #1144 does not solve your issue. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants