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 the rerender loop of profile hero data #985

Merged
merged 5 commits into from
Dec 24, 2021

Conversation

vidvidvid
Copy link
Collaborator

@vidvidvid vidvidvid commented Dec 20, 2021

Overview

What features/fixes does this PR include?

As the title suggests + refactored the other player profile sections' animations with the custom useAnimation hook.
Renamed useAnimation to useAnimateProfileChanges.

Please provide the GitHub issue number

Closes #984

Follow up Improvement Ideas

Implementation

Describe technical (nontrivial / non-obvious) parts of your code

Read the comment

paired-with: @firattale

@vercel
Copy link

vercel bot commented Dec 20, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/metafam/the-game/FkrtrC9EhfrELWHQoYJ7G4G3rr1i
✅ Preview: https://the-game-git-fix-rerender-profile-hero-data-metafam.vercel.app

@vidvidvid vidvidvid self-assigned this Dec 20, 2021
@vidvidvid vidvidvid added the ready-for-review Add this label to your PR when its ready for review label Dec 20, 2021
@vidvidvid vidvidvid requested review from lucidcyborg and removed request for alalonde December 20, 2021 20:20
@firattale
Copy link
Contributor

Hi @vidvidvid , I fixed that UI issue in my #962 issue, this was a broad issue that I created and I sent my commits to that branch. Maybe we can deploy that issue. You can check my fix/several-ui-improvements branch. The problem was happening because useAnimation is having updateFN as a dependant and that was creating an infinite loop, so just removing that was successful.

useEffect(() => { setAnimation('fadeOut'); setTimeout(() => { updateFN(); setAnimation('fadeIn'); }, 400); // eslint-disable-next-line react-hooks/exhaustive-deps }, [depends]);

@vidvidvid
Copy link
Collaborator Author

Hi @vidvidvid , I fixed that UI issue in my #962 issue, this was a broad issue that I created and I sent my commits to that branch. Maybe we can deploy that issue. You can check my fix/several-ui-improvements branch. The problem was happening because useAnimation is having updateFN as a dependant and that was creating an infinite loop, so just removing that was successful.

useEffect(() => { setAnimation('fadeOut'); setTimeout(() => { updateFN(); setAnimation('fadeIn'); }, 400); // eslint-disable-next-line react-hooks/exhaustive-deps }, [depends]);

aaaa, okay, i see. will fix my pr than to match your solution and test if the rest of the components where i used useAnimation are updating and animating as expected 👍

@vidvidvid vidvidvid removed the ready-for-review Add this label to your PR when its ready for review label Dec 20, 2021
@vidvidvid vidvidvid changed the title Fix the rerender loop of profile hero data [WIP] Fix the rerender loop of profile hero data Dec 20, 2021
@vidvidvid
Copy link
Collaborator Author

The rest of the components were subscribed to the same player or user object that changed each time one of the sections' data changed, so the rest of the sections got animated as well. I solved this by combining your solution and mine - so not listing the updateFN in dependencies and still comparing previous value to current value.

@firattale
Copy link
Contributor

LGTM

Copy link
Contributor

@firattale firattale left a comment

Choose a reason for hiding this comment

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

LGTM!

@vidvidvid vidvidvid changed the title [WIP] Fix the rerender loop of profile hero data Fix the rerender loop of profile hero data Dec 21, 2021
@vidvidvid vidvidvid added the ready-for-review Add this label to your PR when its ready for review label Dec 21, 2021
@lucidcyborg lucidcyborg merged commit 7ee77db into develop Dec 24, 2021
@lucidcyborg lucidcyborg deleted the fix/rerender-profile-hero-data branch December 24, 2021 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review Add this label to your PR when its ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Profile hero fields are flashing
3 participants