Fix useEffect deps causing toast spam on EarnPage#1082
Fix useEffect deps causing toast spam on EarnPage#1082kunal-595 wants to merge 1 commit intojoinmarket-webui:v2from
Conversation
There was a problem hiding this comment.
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
startMakermutation object in useEffect deps with specific propertiesstartMaker.isSuccessandstartMaker.reset - Replaced entire
stopMakermutation object in useEffect deps with specific propertiesstopMaker.isSuccessandstopMaker.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.
|
I guess this was introduced in a recent PR when the |
|
I am not experiencing this behaviour - it is currently not optimal, but I do not see what this fixes. Can you elaborate? |
|
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? |
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