-
Notifications
You must be signed in to change notification settings - Fork 265
Jon/fix/coinrank-loading #5544
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
base: develop
Are you sure you want to change the base?
Jon/fix/coinrank-loading #5544
Conversation
if (lastSceneFiat !== coingeckoFiat) { | ||
// Clear cache if we changed the fiat while outside of this scene | ||
debugLog(LOG_COINRANK, 'Clearing coinRankingDatas cache') | ||
coinRanking.coinRankingDatas = [] | ||
lastStartIndex.current = 1 | ||
setDataSize(0) | ||
setRequestDataSize(QUERY_PAGE_SIZE) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just put this in useMount
hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment
#5544 (comment)
We need to pass mounted.current around separately anyway, so might as well fold
the changes into this existing effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using useMount
for the purpose of avoid the eslint-disable-next-line
rule hack
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this // eslint-disable-next-line react-hooks/exhaustive-deps
added? Is there an alternative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the cause of the actual bug in the task - this cleanup fn is appropriate only for when the scene is still mounted, implying that the fiat changed while the scene was mounted, so clearing everything was appropriate.
It's inappropriate to run this cleanup when the scene unmounts, which was happening in the original implementation. We lose the cache in that case, which defeats the purpose of the cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for the eslint-disable-next-line
rule hack though? Seeing this hack is a red flag. I'm trying to understand why it's necessary and perhaps why another approach wasn't taken.
// Queries should update this, but just in case: | ||
lastSceneFiat = coingeckoFiat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not put this in a useUnmount
hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment
#5544 (comment)
We need to pass mounted.current around separately anyway, so might as well fold
the changes into this existing effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why I suggest useUnmount
is to avoid the disabled eslint rule hack.
This also requires keeping track of the scene's last known fiat in case it changes while the scene is unmounted, which should result in a clearing of the cache.
7539af4
to
e954364
Compare
e954364
to
7c1c8d7
Compare
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
noneRequirements
If you have made any visual changes to the GUI. Make sure you have: