move: Cancel long running promises on react-router navigation#155
Merged
move: Cancel long running promises on react-router navigation#155
Conversation
Closed
lubej
reviewed
Jan 14, 2025
349aee3 to
76ee509
Compare
Deployed to Cloudflare Pages
|
76ee509 to
14ef1bf
Compare
This was referenced Feb 18, 2025
Merged
14ef1bf to
c7415b2
Compare
This was referenced Feb 18, 2025
c7415b2 to
0b9095e
Compare
lubej
reviewed
Feb 20, 2025
lubej
reviewed
Feb 25, 2025
move/src/useWithdraw.ts
Outdated
lubej
reviewed
Feb 25, 2025
| async function step3(consensusAccount: ConsensusAccount, sapphireAddress: `0x${string}`) { | ||
| // Note: don't use outside state vars. They are outdated. | ||
| try { | ||
| await new Promise(r => setTimeout(r, 1000)) // Handle React StrictMode: step3 is called by useEffect on mount |
Collaborator
There was a problem hiding this comment.
What do you mean by StrictMode? I don't see it included in the code.
I guess this issue comes from different context.
Contributor
Author
There was a problem hiding this comment.
:O we don't have React.StrictMode in this repo?
Collaborator
There was a problem hiding this comment.
Don't think so. I personally remove it, because of double renders, and it is just confusing when you are debugging. And if there is an issue, I manually add it back, for the time being.
lubej
approved these changes
Feb 25, 2025
added 4 commits
February 25, 2025 23:10
Before 8576711 we relied on full reloads when navigating to cancel the deposit/withdraw long running promises. After adding react-router we need to at least cancel repeating the flows (we don't need to cancel a started flow).
Before, useUnmountSignal would trigger when App.tsx was unmounted. That's unintuitive but worked because there's no way to switch between deposit and withdraw without destroying App. After: Parts of useDeposit that were needed for App.tsx are now split away, and step3 is auto-run when useDeposit gets mounted (in Deposit.tsx). And useUnmountSignal triggers when Deposit is unmounted.
Before, useUnmountSignal would trigger when App.tsx was unmounted. That's unintuitive but worked because there's no way to switch between deposit and withdraw without destroying App. After: Parts of useWithdraw that were needed for App.tsx are now split away. useUnmountSignal triggers when Withdraw is unmounted.
ed4169d to
93df517
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before 8576711 we relied on full reloads when navigating to cancel the deposit/withdraw long running promises. After adding react-router we need to at least cancel repeating the flows (we don't need to cancel a started flow).