Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Cleanup EventsOn listeners #44

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

theBGuy
Copy link
Owner

@theBGuy theBGuy commented Aug 15, 2024

Description:

This PR fixes EventsOn being registered multiple times and never cleaned up.

🧠 Rationale behind the change

EventsOn being outside the useEffect hook was causing it to add another event listener every re-render. It should of been inside the hook so it only adds once and then gets cleaned up on unmount

Commits & Changes:

  • AppFooter.tsx
    • Moved EventsOn("update-available") into useEffect
  • App.tsx
    • Moved EventsOn("new-day") into useEffect

🏎 Quality check

  • Are there any erroneous console logs, debuggers or leftover code in your changes?

  • Walk away, take a break, re-read what you filled out above does it make sense if you were coming in cold? What extra context could you provide?

…d up on unmount

- `EventsOn` being outside of the useEffect was causing multiple listeners to be added and never cleaned up...
@theBGuy theBGuy added the bug Something isn't working label Aug 15, 2024
@theBGuy theBGuy merged commit 9079739 into master Aug 15, 2024
1 check passed
@theBGuy theBGuy deleted the bugfix/cleanup-events-on-listeners branch August 15, 2024 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant