Refactor NoticeAlert: Improve Timeout Handling, Simplify Link Logic, and Enhance Cleanup #4744
+23
−17
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.
This pull request refactors the
NoticeAlert
component to improve handling of timeout and cleanup logic, enhance performance, and simplify the rendering logic for the link.Changes:
Refactor Timeout Logic:
useEffect
hook. This change adds aclearTimeout
call within the cleanup function to ensure that timeouts are cleared correctly when the component unmounts or re-renders.Optimized Click Handling:
handleClick
function, ensuring the alert'sremoveAlert
function is called after the leave transition, maintaining synchronization with the animation.Simplified Link Rendering:
link !== ""
) has been simplified tolink &&
to improve readability and avoid unnecessary conditional elements.Code Cleanup:
link === ""
check. The link is now conditionally rendered only whenlink
is provided.Benefits:
Breaking Changes: