-
Notifications
You must be signed in to change notification settings - Fork 15
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
Improve DW v3 performance #1262
base: dw-redesign
Are you sure you want to change the base?
Conversation
|
85ca69a
to
35bf8cc
Compare
@@ -50,7 +50,7 @@ const useFetchWalletFtsSymbols = () => { | |||
const { | |||
data: { listedFts }, | |||
isLoading: isLoadingTokensByType | |||
} = useFetchWalletTokensByType({ includeAlph: true }) | |||
} = useFetchWalletTokensByType({ includeHidden: true }) |
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.
some defaults where changed, hence this diff
id, | ||
skip: isLoadingTokenType || tokenType?.stdInterfaceId !== e.TokenStdInterfaceId.NonFungible | ||
}) | ||
const { data, isLoading } = useQuery(tokenQuery({ id, networkId, isLoadingFtList, skip: !!listedFt })) |
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.
I spent a lot of time thinking "how can I cache the result of a hook so that it doesn't need to be recomputed every time it's called". Specifically, the problematic hook was useFetchToken
. The body of the hook (seen on the left red diff), even though it uses the skip
prop, it still requires a lot of computation.
The idea implemented here is to use Tanstack's native caching mechanism. My moving the code into a queryFn
we benefit from caching. See below for implementation.
35bf8cc
to
25f69cf
Compare
I will explain in detail the thought process behind these changes