MCPcopy Create free account
hub / github.com/atomicdata-dev/atomic-data-browser / useArray

Function useArray

react/src/hooks.ts:377–395  ·  view source on GitHub ↗
(
  resource: Resource,
  propertyURL: string,
  opts?: useValueOptions,
)

Source from the content-addressed store, hash-verified

375 * to empty array) and a callback for validation errors. See {@link useValue}
376 */
377export function useArray(
378 resource: Resource,
379 propertyURL: string,
380 opts?: useValueOptions,
381): [string[] | null, setValue] {
382 const [value, set] = useValue(resource, propertyURL, opts);
383 if (value == null) {
384 return [[], set];
385 }
386 // If .toArray() errors, return an empty array. Useful in forms when datatypes haves changed!
387 // https://github.com/joepio/atomic-data-browser/issues/85
388 let arr = [];
389 try {
390 arr = valToArray(value);
391 } catch (e) {
392 console.log(e, value, propertyURL, resource.getSubject());
393 }
394 return [arr, set];
395}
396
397/** See {@link useValue} */
398export function useNumber(

Callers 15

useServerSearchFunction · 0.90
SideBar.tsxFile · 0.90
InputResourceArrayFunction · 0.90
ResourceSelectorFunction · 0.90
ResourceFormFunction · 0.90
ShareRouteFunction · 0.90
NewFormFunction · 0.90
DrivePageFunction · 0.90
DocumentPageEditFunction · 0.90
DocumentPageShowFunction · 0.90
CollectionFunction · 0.90
EndpointPageFunction · 0.90

Calls 3

valToArrayFunction · 0.90
useValueFunction · 0.85
getSubjectMethod · 0.80

Tested by

no test coverage detected