Skip to content

Commit

Permalink
chore: refactor useEffect deps in staking.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
shibatales committed Jan 9, 2024
1 parent 13f1afc commit 56d9e2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/routes/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const Overview = () => {

useEffect(() => {
initializeData(selectedAccount);
}, [selectedAccount?.address, api]);
}, [selectedAccount, api]);

useEffect(() => {
if (rewardsUserClaimedQuery.fetching || !selectedAccount?.address) return;
Expand All @@ -243,7 +243,7 @@ const Overview = () => {
rewardsUserClaimedQuery.data.stakers[0].totalUnclaimed
);
setTotalUnclaimed(totalUnclaimed);
}, [selectedAccount?.address, rewardsUserClaimedQuery.fetching, rewardsUserClaimedQuery.data]);
}, [selectedAccount, rewardsUserClaimedQuery.fetching, rewardsUserClaimedQuery.data]);

useEffect(() => {
if (rewardsCoreClaimedQuery.fetching || !rewardsCoreClaimedQuery.data?.cores?.length || !selectedAccount?.address) return;
Expand All @@ -255,7 +255,7 @@ const Overview = () => {
);

setCoreEraStakeInfo(uniqueCoreEraStakeInfo);
}, [selectedAccount?.address, stakingCores, rewardsCoreClaimedQuery.data, rewardsCoreClaimedQuery.fetching]);
}, [selectedAccount, stakingCores, rewardsCoreClaimedQuery.data, rewardsCoreClaimedQuery.fetching]);

useEffect(() => {
let unsubs: UnsubscribePromise[] = [];
Expand All @@ -277,7 +277,7 @@ const Overview = () => {
}
});
};
}, [selectedAccount?.address, api, stakingCores, coreEraStakeInfo]);
}, [selectedAccount, api, stakingCores, coreEraStakeInfo]);

return (
<div className="mx-auto w-full flex max-w-7xl flex-col justify-between p-4 sm:px-6 lg:px-8 mt-14 md:mt-0 gap-3">
Expand Down
14 changes: 7 additions & 7 deletions src/routes/staking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -491,16 +491,16 @@ const Staking = () => {

useEffect(() => {
initializeData(selectedAccount);
}, [selectedAccount?.address, api]);
}, [selectedAccount, api]);

useEffect(() => {
if (!selectedAccount) return;
if (!stakingCores) return;
loadDaos();
}, [selectedAccount?.address, stakingCores, totalUserStakedData, api]);
}, [selectedAccount, stakingCores, totalUserStakedData, api]);

useEffect(() => {
if (rewardsUserClaimedQuery.fetching || !selectedAccount?.address) return;
if (rewardsUserClaimedQuery.fetching || !selectedAccount) return;

if (!rewardsUserClaimedQuery.data?.stakers?.length) {
setTotalClaimed(new BigNumber(0));
Expand All @@ -518,11 +518,11 @@ const Staking = () => {
rewardsUserClaimedQuery.data.stakers[0].totalUnclaimed
);
setTotalUnclaimed(claimAllSuccess ? new BigNumber(0) : totalUnclaimed);
}, [selectedAccount?.address, rewardsUserClaimedQuery, claimAllSuccess]);
}, [selectedAccount, rewardsUserClaimedQuery.fetching, rewardsUserClaimedQuery.data, claimAllSuccess]);

useEffect(() => {
loadTotalUserStaked();
}, [selectedAccount?.address, stakingCores, coreEraStakeInfo, userStakedInfo]);
}, [selectedAccount, stakingCores, coreEraStakeInfo, userStakedInfo]);

useEffect(() => {
if (rewardsCoreClaimedQuery.fetching || !rewardsCoreClaimedQuery.data?.cores?.length || !selectedAccount) return;
Expand All @@ -534,7 +534,7 @@ const Staking = () => {
);

setCoreEraStakeInfo(uniqueCoreEraStakeInfo);
}, [selectedAccount?.address, stakingCores, rewardsCoreClaimedQuery]);
}, [selectedAccount, stakingCores, rewardsUserClaimedQuery.fetching, rewardsUserClaimedQuery.data]);

useEffect(() => {
let unsubs: UnsubscribePromise[] = [];
Expand All @@ -556,7 +556,7 @@ const Staking = () => {
}
});
};
}, [selectedAccount?.address, api, stakingCores, coreEraStakeInfo]);
}, [selectedAccount, api, stakingCores, coreEraStakeInfo]);

return (
<div className="mx-auto w-full flex max-w-7xl flex-col justify-between p-4 sm:px-6 lg:px-8 mt-14 md:mt-0 gap-3">
Expand Down

0 comments on commit 56d9e2b

Please sign in to comment.