Add a react hook for useAirdrop - #1879
Conversation
🦋 Changeset detectedLatest commit: 2c23d28 The changes in this PR will be included in the next version bump. This PR includes changesets to release 48 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
BundleMonFiles updated (3)
Unchanged files (147)
Total files change +131B +0.02% Final result: ✅ View report in BundleMon website ➡️ |
trevor-cortex
left a comment
There was a problem hiding this comment.
Summary
Adds a useAirdrop(client) hook to @solana/react that wraps client.airdrop (from ClientWithAirdrop) via useAction. dispatch(address, amount) runs the airdrop with an injected AbortSignal and exposes lifecycle state; data is Signature | undefined (undefined for implementations like LiteSVM that adjust balances without sending a transaction). Mirrors the shape of useSendTransaction faithfully.
PR also ships the README section, a browser test covering idle → running → success + the undefined and rejection branches, a type test covering the positive shape plus four negative cases (bad address, bad amount, missing amount, client without airdrop capability), the index re-export, and a correctly-scoped minor changeset for @solana/react.
Notes for reviewers
- The
abortSignalis passed positionally as the third arg toclient.airdrop(address, amount, abortSignal), which differs fromsendTransaction(input, { abortSignal }). That matches whatClientWithAirdrop.airdropactually accepts — the type tests would fail otherwise — so this is right, just worth being aware of when comparing the two files side by side. - Tests correctly use the local
renderHookfrom__test-utils__/render.tsx(StrictMode-wrapping) per the repo's React testing convention. - No
expect.assertionsconcerns — the async tests all declare it, and the counts match the assertions in eachit.
LGTM — no changes requested.
|
Documentation Preview: https://kit-docs-eoxmytfab-anza-tech.vercel.app |
Merge activity
|
52df81f to
5308c32
Compare
5d122e0 to
2111b77
Compare
5308c32 to
722cab6
Compare
2111b77 to
9d28bf8
Compare
9d28bf8 to
2c23d28
Compare
|
🔎💬 Inkeep AI search and chat service is syncing content for source 'Solana Kit Docs' |

This PR adds a
useAirdrophook, wrapping theairdropfunction fromClientWithAirdropwithuseAction.Following the same pattern as eg
useSendTransaction