Skip to content

feat(typescript): add useRow hook for Vue and React to fix issue #5060 - #5844

Open
rohanranjan0902 wants to merge 1 commit into
clockworklabs:masterfrom
rohanranjan0902:master
Open

feat(typescript): add useRow hook for Vue and React to fix issue #5060#5844
rohanranjan0902 wants to merge 1 commit into
clockworklabs:masterfrom
rohanranjan0902:master

Conversation

@rohanranjan0902

Copy link
Copy Markdown

Description of Changes

Added a new useRow hook for the React and Vue bindings to provide a cleaner developer experience when querying single rows or views that return t.option().

Previously, because the SpacetimeDB host runtime represents all views as tables, the client-generated SDK would type t.option() views as returning an array. This forced developers to manually unwrap the array (e.g. userData?.value[0] ?? undefined). The new useRow hook wraps useTable and automatically returns the first element or undefined.

Fixes #5060

API and ABI breaking changes

None. This is purely an additive feature for the client SDKs.

Expected complexity level and risk

1

This is a trivial, additive change. It simply introduces a thin wrapper around the existing useTable hook to extract the first element.

Testing

  • Verified the TypeScript bindings compile without errors via pnpm run build locally.
  • Reviewers can check that useRow functions as intended in an actual React or Vue app when subscribing to a table or view.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Rohan Ranjan Prasad seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VueJS view return type as t.option still returns an array

2 participants