• Similar to React's useState hook. Returns a Value and a Setter as an array of two items. Value will be undefined if the Resource isn't loaded yet. The generated Setter function can be called to set the value. Be sure to look at the various options for useValueOptions (debounce, commits, error handling).

    // Simple usage:
    const resource = useResource('https://atomicdata.dev/classes/Agent');
    const [shortname, setShortname] = useValue(
    'https://atomicdata.dev/properties/shortname',
    resource,
    );
    // With options:
    const resource = useResource('https://atomicdata.dev/classes/Agent');
    const [error, setError] = useState(null);
    const [shortname, setShortname] = useValue(
    'https://atomicdata.dev/properties/shortname',
    resource,
    {
    commit: true,
    validate: true,
    commitDebounce: 500,
    handleValidationError: setError,
    },
    );

    Parameters

    Returns [JSONValue | undefined, SetValue]

Generated using TypeDoc