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

Challenge 3: fix infinite useEffect loop #244

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

rin-st
Copy link
Member

@rin-st rin-st commented Dec 11, 2024

At some point we changed logic a bit, and

  1. Maximum rolls and winners lengths could be from 0 to 10 because all the data was sliced before updating the state. Reason for this is that we show just last 10 rolls/winners
  2. At our useEffects we have a condition like (rollsHistoryData?.length as number) > rolls.length) so when rollsHistoryData.length becomes more than 10, rolls.length is not - it's still 10, and it means that mentioned condition is always true. So we have setRolls(...) inside that useEffect -> it changes rolls -> it executes that useEffect again etc -> infinite loop. Same for winners

This PR fixes it. Please check and after merging this I'll add changes to extension

Fixes #242

@rin-st rin-st requested a review from Pabl0cks December 11, 2024 21:21
Copy link
Collaborator

@Pabl0cks Pabl0cks left a comment

Choose a reason for hiding this comment

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

It's looking great to me! GJ @rin-st 🙏🙏

@rin-st rin-st merged commit e8efbdc into challenge-3-dice-game Dec 13, 2024
@rin-st rin-st deleted the fix-useffect-infinite-loop branch December 13, 2024 13:18
@rin-st
Copy link
Member Author

rin-st commented Dec 13, 2024

Thanks Pablo!

Extension fix: 913e850

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants