-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
|
@@ -62,7 +62,7 @@ const useSelectRowsWithQuery = (gauges: Gauge[] | undefined) => { | |||
const urlHashes = queryHashes.filter((hash) => !newHashes.includes(hash)) | |||
setSelectRowsHash(urlHashes.concat(newHashes)) | |||
} | |||
}, [isLoading, prevVotedGauges, queryHashes]) | |||
}, [isLoading, prevVotedGauges.map((x) => x.hash).join('-'), queryHashes]) |
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.
will map every render, how about to use a memo value
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.
done
@@ -62,7 +62,7 @@ const useSelectRowsWithQuery = (gauges: Gauge[] | undefined) => { | |||
const urlHashes = queryHashes.filter((hash) => !newHashes.includes(hash)) | |||
setSelectRowsHash(urlHashes.concat(newHashes)) | |||
} | |||
}, [isLoading, prevVotedGauges, queryHashes]) | |||
}, [isLoading, prevVotedGauges.map((x) => x.hash).join('-'), queryHashes]) |
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.
would suggest to fix the ref issue within the useUserVoteGauges 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.
@chefjackson
Do you mean something like this?
const prevGaugesRef = useRef(prevVotedGauges);
const hasChanges = prevGaugesRef.current.some(
(prevGauge, index) => prevGauge.hash !== prevVotedGauges[index]?.hash
);
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.
done
apps/web/src/views/GaugesVoting/components/Table/VoteTable/hooks/useGaugeRows.ts
Outdated
Show resolved
Hide resolved
8be59a3
@@ -35,7 +35,7 @@ export const useUserVoteSlopes = () => { | |||
userInfo?.cakePoolProxy, | |||
publicClient, | |||
], | |||
|
|||
initialData: [], |
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.
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
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.
or use placeholderData
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.
placeholderData behaves the same if i am not mistaken
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.
yeah, my mistake
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.
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.
PR-Codex overview
This PR modifies the
useUserVoteGauges
hook in theapps/web/src/views/GaugesVoting/hooks/useUserVoteGauges.ts
file, focusing on the handling of thepublicClient
and the structure of the returned data.Detailed summary
publicClient
to its original form.initialData
property in the query options to an empty array.data
instead of using a fallback to an empty array.