Skip to content

Latest commit

 

History

History
36 lines (30 loc) · 857 Bytes

File metadata and controls

36 lines (30 loc) · 857 Bytes

react-native-app-helpers/CustomElementTableColumn

Describes the schema of a column in a table which has a custom renderer.

Usage

import type { CustomElementTableColumn } from "react-native-app-helpers";

type TableRow = {
  readonly columnA: null | string;
  readonly columnB: null | number;
  readonly columnC: 0 | 1 | 2 | 3;
  readonly columnD: null | boolean;
};

const example: CustomElementTableColumn<
  `exampleKeyA` | `exampleKeyB` | `exampleKeyC` | `exampleKeyD`,
  TableRow,
  `Example Context`
> = {
  type: `customElement`,
  label: `Example Label B`,
  width: 5,
  render(tableRow, context) {
    return (
      <Text>{tableRow.exampleKeyA}</Text>
    );
  },
  containsSearchTerm(tableRow, filter, context) {
    const value = tableRow.exampleKeyA;

    return typeof value === `string` && value.includes(filter);
  },
};