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] Some react render issues #214

Merged
merged 7 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion packages/react-app/src/components/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ export default function Dashboard() {
const theme = useTheme();
const [dashboardModel, setDashboardModel] = useState<DashboardModel>();
useEffect(() => {
getDashboardInfo().then(setDashboardModel);
let isSubscribed = true;
Corantin marked this conversation as resolved.
Show resolved Hide resolved
getDashboardInfo().then((innerDashboardModel) => {
if (isSubscribed) {
setDashboardModel(innerDashboardModel);
}
});
return () => {
isSubscribed = false;
};
}, []);

return (
Expand Down
7 changes: 6 additions & 1 deletion packages/react-app/src/components/modals/challenge-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export default function ChallengeModal({ claim, challengeDeposit, onClose = noop
}
buttons={[
<WalletBallance
key="WalletBallance-1"
askedTokenAmount={
isFeeDepositSameToken && challengeFee
? {
Expand All @@ -307,7 +308,11 @@ export default function ChallengeModal({ claim, challengeDeposit, onClose = noop
setIsEnoughBalance={setIsEnoughBalance}
/>,
challengeFee && !isFeeDepositSameToken && (
<WalletBallance askedTokenAmount={challengeFee} setIsEnoughBalance={setIsEnoughBalance} />
<WalletBallance
key="WalletBallance-2"
askedTokenAmount={challengeFee}
setIsEnoughBalance={setIsEnoughBalance}
/>
),
<AmountFieldInput
key="challengeDeposit"
Expand Down
2 changes: 2 additions & 0 deletions packages/react-app/src/components/modals/fund-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ export default function FundModal({ quest, onClose = noop }: Props) {
buttons={[
quest.rewardToken && (
<WalletBallance
key="fundAmount"
askedTokenAmount={values.fundAmount}
setIsEnoughBalance={setIsEnoughBalance}
/>
),
<Button
key="buttonFund"
icon={<GiTwoCoins />}
type="submit"
form="form-fund"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ export default function ScheduleClaimModal({
/>
}
buttons={[
<WalletBallance askedTokenAmount={claimDeposit} setIsEnoughBalance={setIsEnoughBalance} />,
<WalletBallance
key="WalletBallance-claimDeposit"
askedTokenAmount={claimDeposit}
setIsEnoughBalance={setIsEnoughBalance}
/>,
<AmountFieldInputFormik
key="claimDeposit"
id="claimDeposit"
Expand Down
13 changes: 10 additions & 3 deletions packages/react-app/src/components/views/quest-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ export default function QuestDetail() {
const [a, setA] = useState<boolean>();

useEffect(() => {
let isSubscribed = true;

setPage(ENUM_PAGES.Detail);
const fetchQuestAsync = async (questAddress: string) => {
const questResult = await fetchQuest(questAddress);
if (!questResult) toast('Failed to get quest, verify address');
else setQuest(questResult);
setA(true);
if (isSubscribed) {
if (!questResult) toast('Failed to get quest, verify address');
else setQuest(questResult);
setA(true);
}
};
if (id) fetchQuestAsync(id);
return () => {
isSubscribed = false;
};
}, [id]);

return (
Expand Down