Reference · React

useVersions(uri, options?)

Next release: this page describes techne-sdk/types, which is not in techne-sdk 0.3.4 yet. With techne-sdk 0.3 today shows the released API.

React hooktechne-sdk/reactIn the SDK, techne.versions

A record as its versions, for a versions pill, a field-conflict badge and a versions sheet. It also holds which version the person picked.

useRecord and useRecordQuery never carry versions. This is the one read that does. The ranking comes from the same Rust the curator composes with, run as WebAssembly, so the screen and the curator cannot disagree.

Parameters

NameTypeWhat it is
urirequiredstring | null | undefinedThe record's at:// address. A null or undefined URI reads nothing.
options.enabledbooleanfalse holds the read.
options.subscribedbooleanfalse keeps a hidden screen off the cache's updates.

Returns TanStack's query result, plus

NameTypeWhat it is
itemItem<T> | null | undefinedThe composed record. Once a version is selected, that version's own values, with the same uri and verdict. null when nothing is there, undefined until read.
versionsVersionEntry[]Every version as the versions sheet lists them. Empty until read.
conflicts{ [field]: number }Each field whose ranked versions disagree, and how many values they give.
selectedstring | nullThe selected version's URI, or null for the composition.
select(uri | null) => voidShow one version. null goes back to the composition. A URI that is not among the versions is ignored.
bylineVersionEntry | nullThe version that speaks first. The one selected, else the composition's byline.
pill{ label, count, accessibilityLabel } | nullThe version pill, e.g. “from Backstreet Museum calendar · 2 sources”.
conflict(field) => { count, accessibilityLabel } | nullThe field-conflict badge for one field or several. null under 2.
stateEventState | nullThe state the versions views draw. null until read, and for a record answered privately.

Each version

uristringThe version's own address.
didstringIts author.
name · handlestringWho to show it as.
group'sources' | 'verified' | 'others'Where the sheet lists it. Sources are rank 1, verified accounts rank 2, everyone else rank 3.
verifiedbooleanA verification record by an issuer the root endorses is about its author.
showingbooleanIt is the version being shown.
differs · samestring[]The fields where it says something other than what is shown, and where it agrees.
recordobjectIts values.

Its key is ['techne', 'versions', uri, did]. A selection resets when the URI changes, and a refetch that drops the selected version clears it.

A name with its conflict badge and version pill
The same read as a call

useVersions(uri) is useQuery(techne.versionsOptions(uri)), with the selection kept in the hook. techne.versions

Calls commons.getVersions, or query.getRecords → for a record answered privately