docs(frontend): adopt useTrackedDataSWR, useAction, and SOL/lamports helpers - #63
Conversation
Greptile SummaryThis documentation update modernizes the Solana frontend guidance for Kit and React v7.
Confidence Score: 4/5The documentation changes appear sound, but the unsigned commits must be replaced with verified commits before merging. The previously reported abort-signal issue is fixed by forwarding the signal to Important Files Changed
Reviews (4): Last reviewed commit: "docs(kit): drop unreleased v8 transactio..." | Re-trigger Greptile |
…helpers Incorporates Kit team feedback on the React reference: - balance/live account data now documented via useTrackedDataSWR, matching the Kit example app, instead of a hand-rolled fetch + subscription pair - transaction sending wrapped in useAction for lifecycle state and abort-on-resend - sol/solToLamports/lamportsToSol/formatDecimalFixedPoint documented; fixes a broken example that passed a Sol fixed-point value where an instruction expects Lamports All snippets typecheck against @solana/kit 7.0.0, @solana/react 7.0.0, and tsc 7.0.2 under strict mode.
ed422bf to
772740a
Compare
|
Thanks — one applied, one is a false positive. P2, abort signal discarded — fixed in P1, unsigned commit — not reproducible. Both Signing is on ( |
…rcing Addresses review feedback from the Kit team: - note that useTrackedData/useRequest/useSubscription each have SWR and TanStack Query counterparts - @solana/promises is re-exported from @solana/kit as of v8; the explicit install is only needed on v7 - add the useSendTransaction / useSendTransactions / usePlanTransaction / usePlanTransactions hooks landing in v8, with the useAction pattern kept as the v7 path
The useSendTransaction family is merged on kit main but not published. Documenting it risks agents importing exports that do not resolve against the v7 baseline the skill targets.
dev-jodee
left a comment
There was a problem hiding this comment.
docs(frontend): adopt useTrackedDataSWR, useAction, and SOL/lamports helpers. Greptile review green. Approved.
Updates the frontend and React references for @solana/kit 7 / @solana/react 7. Incorporates feedback from Callum McIntyre on the Kit team; both of his suggestions are already applied upstream in
solana-foundation/templates(use-balance.ts,use-send.tsx), so this brings the skill in line.Closes DEV-845
What changed
references/frontend.mduseTrackedDataSWR, modeled on the Kit example app'sBalance.tsx. Previously the docs described the problem but left the reader to hand-roll agetBalance+accountNotificationspair.useAction, replacing the bare async function and a stale "Kit will ship dedicated hooks shortly" note.swr/@tanstack/react-queryto the dependency list as the optional peer deps of the adapter subpaths.references/kit/react.md— expanded the data-hooks table into realuseTrackedData/useTrackedDataSWRanduseActionsections. This file is now the canonical hook reference;frontend.mdkeeps app-shaped examples and links here.references/kit/overview.md— new SOL ↔ Lamports section coveringsol,solToLamports,lamportsToSol, andformatDecimalFixedPoint.SKILL.md— linkskit/react.mddirectly. It was previously reachable only viakit/overview.md, which is likely why the hook content got duplicated in the first place.Bugs fixed along the way
frontend.mdpassedsol('0.01')as an instructionamount.sol()returns a fixed-point object ({ raw, decimals, ... }), not a bigint, so the example could not have worked. NowsolToLamports(sol('0.01')).useSelectAccountwas listed as an action hook returningdispatch. It is synchronous and returns the boundselectAccountfunction directly —const { dispatch } = useSelectAccount(client)would yieldundefined.Verification
Every referenced API was checked against the installed
.d.tsfiles, and all snippets were compiled in a scratch project (@solana/kit@7.0.0,@solana/react@7.0.0,@solana/kit-plugin-{rpc,wallet},@solana-program/system, tsc 7.0.2,strict) — clean.