fix(governance): removed loop caused by rewards epoch refresh (#4864)
This commit is contained in:
parent
525773773a
commit
9cbd6baccd
@ -1,4 +1,4 @@
|
|||||||
import { useMemo, useEffect, useState, useCallback } from 'react';
|
import { useMemo, useEffect, useState, useCallback, useRef } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { AsyncRenderer, Pagination } from '@vegaprotocol/ui-toolkit';
|
import { AsyncRenderer, Pagination } from '@vegaprotocol/ui-toolkit';
|
||||||
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
||||||
@ -86,12 +86,18 @@ export const EpochIndividualRewards = ({
|
|||||||
[epochId, page, refetch, delegationsPagination, pubKey]
|
[epochId, page, refetch, delegationsPagination, pubKey]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const prevEpochIdRef = useRef<number | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// when the epoch changes, we want to refetch the data to update the current page
|
if (prevEpochIdRef.current === null) {
|
||||||
if (data) {
|
prevEpochIdRef.current = epochId;
|
||||||
|
} else if (epochId !== prevEpochIdRef.current) {
|
||||||
|
// When the epoch changes, we want to refetch the data to update the current page
|
||||||
refetchData();
|
refetchData();
|
||||||
}
|
}
|
||||||
}, [epochId, data, refetchData]);
|
|
||||||
|
prevEpochIdRef.current = epochId;
|
||||||
|
}, [epochId, refetchData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AsyncRenderer
|
<AsyncRenderer
|
||||||
|
Loading…
Reference in New Issue
Block a user