Skip to main content

useField

Get information about a specified field. Rerendering is triggered when a field property changes.

If no ID is passed in, undefined is returned.

Parameters

NameTypeDescription
fieldIdstring | undefinedThe ID for this field.

Returns

Field | undefined

Example

import { useField } from '@apitable/widget-sdk';

// show field name
function FieldName() {
const field = useField('fldXXXXXXX');
return <p>{field.name}</p>
}

useField(datasheet, fieldId): Field | undefined

Support for loading the corresponding datasheet data field.

Parameters

NameTypeDescription
datasheetDatasheet | undefinedDatasheet instance, by useDatasheet get.
fieldIdstring | undefinedThe ID for this field

Returns

Field | undefined

Example

import { useField, useDatasheet } from '@apitable/widget-sdk';

// show field name corresponding to the datasheetId(dstXXXXXXXX) datasheet
function FieldName() {
const datasheet = useDatasheet('dstXXXXXXXX');
const field = useField(datasheet, 'fldXXXXXXX');
return <p>{field.name}</p>
}