Skip to Content
Hooks

useKivaFieldComponent

Resolve the native form field, value renderer or inline editor for a Kiva field type — plus the shared FORM_FIELD_MAP / VALUE_RENDERER_MAP registries and IField helpers.

iOSAndroidExpo Go

Installation

pnpm dlx @kivacore/ui-cli add @kivacore/rn-hooks-use-kiva-field-component

Depends on @kivacore/rn-form-fields, @kivacore/rn-value-renderers and @kivacore/rn-editable-value (installed with it).

Overview

Native port of the web useKivaFieldComponent. The registries map every IFieldType to native components:

  • form-field — the IField adapter KivaFieldDynamic, typed as ComponentType<KivaFormFieldProps> (field, value, onChange, record, onCompanionChange, …). null for types without a native editor mapping (computed / system types).
  • value-renderer — the KivaValue* renderer; unknown types fall back to KivaValueText.
  • editable-value — always EditableValue, which dispatches by field type.

The web-only kinds data-grid-cell-variant and tanstack-column-def live with the native data-grid package.

Usage

import { useKivaFieldComponent } from '@/hooks/kiva-native/use-kiva-field-component';

function FieldRow({ field, record, onChange }) {
  const Form = useKivaFieldComponent(field.type, 'form-field');
  const Value = useKivaFieldComponent(field.type, 'value-renderer');

  if (!Form) return <Value field={field} value={record[field.slug]} record={record} />;

  return (
    <Form
      field={field}
      value={record[field.slug]}
      record={record}
      onChange={value => onChange(field.slug, value)}
      onCompanionChange={onChange} />
  );
}
import { extractEnumOptions, toIField } from '@/hooks/kiva-native/use-kiva-field-component';

// DataSourceField (app-utils) → IField + inline options
const field = toIField(dataSourceField);
const options = extractEnumOptions(dataSourceField);

API Reference

useKivaFieldComponent(fieldType, kind)

ParamTypeDescription
fieldTypeIFieldTypeField type
kind'form-field' | 'value-renderer' | 'editable-value'Render context

Returns KivaFieldComponentResult<K> — ComponentType<KivaFormFieldProps> \| null, ComponentType<KivaValueProps> or typeof EditableValue.

Exports

ExportDescription
FORM_FIELD_MAPIFieldType → controlled KivaField* component
VALUE_RENDERER_MAPIFieldType → KivaValue* renderer
GROUPABLE_FIELD_TYPESField types usable for row grouping
extractEnumOptions(field)Inline options from field.enums / options.options (camel + snake case metadata, user names from firstname lastname)
toIField(field)Loose KivaFieldLike → IField
getFieldValue(row, slug)Safe value read
readFieldFormat(field)KivaFieldFormat from field.format with flat fallbacks
KivaValueDynamicDynamic value renderer (re-export)

Types

TypeDescription
KivaFieldComponentKind'form-field' | 'value-renderer' | 'editable-value'
KivaFieldComponentResult<K>Resolved component type
KivaFieldLikeLoose field shape (IField or DataSourceField)
KivaFieldFormat{ currency?, decimalPrecision?, thousandSeparator?, symbolPosition?, ratingMax?, ratingIcon? }

On this page