Skip to content

[Maintenance]: useSplToken README missing critical return values and options #114

@resourcefulmind

Description

@resourcefulmind

Summary

The useSplToken example in packages/react-hooks/README.md only documents 4 of 14 return values. Critical properties for error handling, transaction verification, and state management are missing.

Currently documented:

  • balance, send, isSending, owner

Missing from documentation:

Priority 1 — Critical for production apps:

  • error — Error from balance fetching
  • sendError — Error from transfer attempt
  • status — Overall hook status ('disconnected' | 'error' | 'loading' | 'ready')
  • sendStatus — Transfer status ('idle' | 'loading' | 'success' | 'error')
  • sendSignature — Transaction signature after successful transfer (needed for Explorer links)

Priority 2 — Quality of life:

  • refresh() — Manually refresh balance
  • refreshing — True while refreshing
  • resetSend() — Clear error state after failed attempt
  • helper — Low-level helper for advanced use
  • isFetching — True while loading balance

Also undocumented:

  • UseSplTokenOptions — Optional second parameter with commitment, owner, revalidateOnFocus, etc.

Motivation

  • Without error/sendError, developers can't show error messages — transfers fail silently.
  • Without sendSignature, developers can't link to Solana Explorer — users have no way to verify transactions.
  • Without status/sendStatus, developers can't show proper loading/success UI states.
  • These gaps cause production apps to feel broken or untrustworthy, especially for a library approaching 1.0.

Scope / constraints

Documentation-only change to packages/react-hooks/README.md. No code changes required.

Suggested approach:

  1. Expand the useSplToken example to show error handling
  2. Add a table listing all return values
  3. Document the optional second parameter (UseSplTokenOptions)

Additional context

Source code reference: packages/react-hooks/src/hooks.ts lines 477-607

The return type definition shows all 14 properties, but the README example only uses 4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions