Skip to main content

usePrimaryField

Get information of primary field. Rerendering is triggered when a field property changes.

Parameters

NameType
datasheet?Datasheet

Returns

null | Field

primary field info.

Example

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

// Show primary field name
function PrimaryFieldName() {
const field = usePrimaryField();
return <p>{field.name}</p>
}

// Show corresponding datasheetId(dstXXXXXXXX) Name of the primary field of the datasheet
function DatasheetPrimaryFieldName() {
const useDatasheet = useDatasheet('dstXXXXXXXX');
const field = usePrimaryField(useDatasheet);
return <p>{field.name}</p>
}