Reference · React
useRecord(uri, options?)
React hooktechne-sdk/reactIn the SDK, techne.get
One record by its address, as a React read. data is its item, or null when nothing valid is there.
The URI sets the type. A Uri<Place> answers a place, and a bare string answers unknown. A null or undefined URI reads nothing, so you can pass one that is not there yet.
Parameters
| Name | Type | What it is |
|---|---|---|
urirequired | string | null | undefined | The record's at:// address. Usually an item's uri from another read. |
options.prefer | 'mine' | The signed-in person's own version, when they have one. Else the curated record. |
options.exact | boolean | Exactly the record at the URI, never another copy. |
options.include | 'valid' | 'all' | 'valid' is the default, and a record that is not valid answers null. 'all' answers any verdict. |
options.enabled | boolean | false holds the read. |
Also subscribed: false, to keep a hidden screen off the cache's updates.
Returns TanStack's query result
| Name | Type | What it is |
|---|---|---|
data | ValidItem<T> | null | undefined | The item. null when nothing is there, undefined until read. |
isPending | boolean | True until there is data. |
error | Error | null | Why the read failed, if it did. |
refetch | () => Promise | Read again now. |
Its key is ['techne', 'record', uri, options, did]. useRecord never carries versions. useVersions does.
A place, by the address in the URL
Place.uri types the string, so place.record is a Place. It checks nothing.
The same read without React
useRecord(uri, options) is useQuery(techne.getOptions(uri, options)).
Calls commons.getVersions, or query.getRecords → for an exact or private record