-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[docs] [sdk] Update e2e counter docs and template #20044
[docs] [sdk] Update e2e counter docs and template #20044
Conversation
…ystenLabs#20043)" This reverts commit 4df3956.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Skipped Deployments
|
Dan already knows, but doc changes lg |
</Container> | ||
); | ||
const { mutate: signAndExecute } = useSignAndExecuteTransaction(); | ||
const [waitingForTxn, setWaitingForTxn] = useState(false); |
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 useSignAndExecuteTransaction already has state for this, and returns the following properties that can be used:
isIdle
, isPending
, isSuccess
, isError
, and status
.
You probably want isPending
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.
Tried this. The issue is that waitingForTxn is true
until after the transaction is waited for. isPending
becomes false after the transaction is executed, not waited for though.
with waitingForTxn
Screen.Recording.2024-11-01.at.9.32.48.AM.mov
with isPending
Screen.Recording.2024-11-01.at.9.34.10.AM.mov
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.
isSuccess
should work though
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 ended up using isSuccess
and isPending
since when I just used isSuccess
, the spinner won't show after the button is pressed but before the user accepts the transaction.
if (objectId) { | ||
onCreated(objectId); | ||
} | ||
onSuccess: ({ digest }) => { |
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.
If you make this an async function, and await the waitForTransaction, you should be able to uses the isPending
status from the useSignAndExecuteTransaction hook, rather than tracking your own state
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.
Addressed. Had to use isSuccess
as well as isPending
. Mentioned in previous comment
sdk/create-dapp/templates/react-e2e-counter/src/CreateCounter.tsx
Outdated
Show resolved
Hide resolved
…AndExecuteTransaction" This reverts commit cf6a029.
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.
Just a few things. Everything else looks good to me!
This PR fixes an issue with the e2e counter template where sometimes the data is refetched too soon after a transaction is executed.