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: 🐛 Fix infinit refresh bugs #10943

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/web/src/views/GaugesVoting/hooks/useUserVoteGauges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useQuery } from '@tanstack/react-query'
import useAccountActiveChain from 'hooks/useAccountActiveChain'
import { useGaugesVotingContract } from 'hooks/useContract'
import { useMemo } from 'react'
import { publicClient as getPublicClient } from 'utils/viem'
import { isAddressEqual } from 'utils'
import { publicClient as getPublicClient } from 'utils/viem'
import { Hex, zeroAddress } from 'viem'
import { useVeCakeUserInfo } from 'views/CakeStaking/hooks/useVeCakeUserInfo'
import { CakePoolType } from 'views/CakeStaking/types'
Expand Down Expand Up @@ -35,7 +35,7 @@ export const useUserVoteSlopes = () => {
userInfo?.cakePoolProxy,
publicClient,
],

initialData: [],
Copy link
Collaborator

@memoyil memoyil Nov 15, 2024

Choose a reason for hiding this comment

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

if initial data used isLoading will be false always even there is no real fetch, so i would suggest to memoize the data when returning

Copy link
Contributor

Choose a reason for hiding this comment

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

or use placeholderData

Copy link
Collaborator

Choose a reason for hiding this comment

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

placeholderData behaves the same if i am not mistaken

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, my mistake

Copy link
Contributor Author

@chef-ryan chef-ryan Nov 15, 2024

Choose a reason for hiding this comment

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

Hi, I checked, momoyil correct.

Since set either initialData or placeholderData will suggest isloading to be false.
Let's assume this is actually what should be the standard behavior.
Introduct a memod state is too complex for this easy requirement.

So I perfer to do no changes here.
Let's migrate to async atom in future.

queryFn: async (): Promise<VoteSlope[]> => {
if (!gauges || gauges.length === 0 || !account || !publicClient) return []

Expand Down Expand Up @@ -88,7 +88,7 @@ export const useUserVoteSlopes = () => {
})

return {
data: data ?? [],
data,
refetch,
isLoading,
}
Expand Down
Loading