-
Notifications
You must be signed in to change notification settings - Fork 54
Conversation
|
@@ -279,6 +279,17 @@ export function useUserClaims(account: Account, optionalChainId?: SupportedChain | |||
return { claims: claimKey ? claimInfo[claimKey] : null, isLoading } | |||
} | |||
|
|||
let FETCH_DEPLOYMENT_TIMESTAMP_PROMISE: Promise<number> | null = null |
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.
why CAPITAL letters if its not a constant?
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.
The same thing they used here
cowswap/src/state/claim/hooks.ts
Line 28 in 1c086d4
let FETCH_CLAIM_MAPPING_PROMISE: Promise<ClaimAddressMapping> | null = null |
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.
well, it sounds like also bad there :)
anyways, just a nit. Constants are capitalised, but this is not one
function fetchDeploymentTimestamp(vCowContract: VCowType) { | ||
return ( | ||
FETCH_DEPLOYMENT_TIMESTAMP_PROMISE ?? | ||
(FETCH_DEPLOYMENT_TIMESTAMP_PROMISE = vCowContract.deploymentTimestamp().then((ts) => { |
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.
Can we use await?
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.
I would keep then here.
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.
Not against it, but any reason in particular?
it seems more readable to use await
Hey @nenadV91 , I see an infinite loader when I open the Claim page as a not connected user: |
@elena-zh Good catch, should be fixed now. |
@nenadV91 , works fine. |
@@ -288,17 +304,28 @@ function useDeploymentTimestamp(): number | null { | |||
const { chainId } = useActiveWeb3React() | |||
const vCowContract = useVCowContract() | |||
const [timestamp, setTimestamp] = useState<number | null>(null) | |||
const [isMounted, setIsMounted] = useState(true) |
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.
I think you should use a useRef
instead.
Otherwise the isMounted flag will cause the issue you are trying to prevent here.
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.
Good suggestion, looks like its working great.
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.
Approved but keep in mind now that you changed the base branch git thinks you are adding a bunch of commits you didn't do.
Either rebase/cherry-pick against release branch or merge it to sync the history
console.log('vCowContract Deployment Timestamp fetch failed') | ||
} | ||
}) | ||
}, [chainId, isMounted, timestamp, vCowContract]) |
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.
It's still depending on timestamp
from outer context which it shouldn't
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.
SOFT approve.
Make sure you fix the base branch / commits before merging.
git rebase --onto
would help. Otherwise cherry-pick
@@ -279,6 +279,17 @@ export function useUserClaims(account: Account, optionalChainId?: SupportedChain | |||
return { claims: claimKey ? claimInfo[claimKey] : null, isLoading } | |||
} | |||
|
|||
let FETCH_DEPLOYMENT_TIMESTAMP_PROMISE: Promise<number> | null = null |
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.
well, it sounds like also bad there :)
anyways, just a nit. Constants are capitalised, but this is not one
ca1caa2
to
abd4025
Compare
abd4025
to
5272389
Compare
* Creates a ref that can be used to solve the issue of | ||
* "Can't perform a React state update on an unmounted component." | ||
*/ | ||
function useIsMounted() { |
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.
why not do this in a more general place and export it. Its a general solution, right?
Summary
This fixes few existing errors in console
issue with key props

issue with calling fetch deployment timestamp multiple times and also memory leak issues

issue with flashing screen before loader shows up
To test
Edited anxo:
Just some test. Pls nenad ignore
LINEAR-13