Fix: Resolve infinite loop for registration success toast #1247
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This pull request resolves the bug where the success toast notification on the registration page was triggered in a continuous loop.
Fixes #1246
Summary of Changes
The root cause was an issue in the state management logic following a successful user registration. The isSuccess state was being set to true but was never reset, causing any component dependent on this state to re-render and re-trigger the toast display function.
This PR introduces the following changes:
Refactored the registration submission handler to reset the success state immediately after the toast notification is dispatched.
Ensured the effect that triggers the toast only runs once when the success state changes from false to true.
How to Test
Check out this branch.
Navigate to the registration page (/register).
Fill in the form with valid user details and click "Create Account".
Verify that the "Account created successfully!" toast appears only once.
Verify that the toast fades out or can be dismissed, and no further toasts appear afterward.