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

[Fix] Prevent useEffect infinite loops #3174

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

arielj
Copy link
Collaborator

@arielj arielj commented Oct 29, 2023

This PR fixes a problem I noticed in some components in the Advanced screen that include the state variable as a dependency for useEffects that update that state. This can lead to infinite loops and it's not correct to do it.

This can be seen when running a clean install of Heroic and going to Settings > Advanced, there's an infinite loop in the dev tools console.

This is solved once the experimental features are modified, but we shouldn't have this loop to begin with.

The useEffect that updates the Copy to clipboard status is safe because it returns early if false so it doesn't call a state setter.


Use the following Checklist if you have changed something on the Backend or Frontend:

  • Tested the feature and it's working on a current and clean install.
  • Tested the main App features and they are still working on a current and clean install. (Login, Install, Play, Uninstall, Move games, etc.)
  • Created / Updated Tests (If necessary)
  • Created / Updated documentation (If necessary)

@arielj arielj added the pr:ready-for-review Feature-complete, ready for the grind! :P label Oct 29, 2023
@arielj arielj requested review from a team, flavioislima, CommandMC, Etaash-mathamsetty, Nocccer and imLinguin and removed request for a team October 29, 2023 22:03
Copy link
Collaborator

@CommandMC CommandMC left a comment

Choose a reason for hiding this comment

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

Almost like someone didn't know how React worked back when they wrote this code (to clarify, this "someone" was me)

Thanks!

@flavioislima
Copy link
Member

Almost like someone didn't know how React worked back when they wrote this code (to clarify, this "someone" was me)

Thanks!

no worries about that, I also did this mistake a few times 👍🏽

Copy link
Member

@flavioislima flavioislima left a comment

Choose a reason for hiding this comment

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

Good catch!

@flavioislima flavioislima merged commit 75ed032 into main Oct 30, 2023
13 checks passed
@flavioislima flavioislima deleted the prevent-infinite-useEffect-loops branch October 30, 2023 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:ready-for-review Feature-complete, ready for the grind! :P
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants