Skip to content

Commit a010c10

Browse files
committed
immutable types / textEditor is a render function
1 parent b21706c commit a010c10

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

README.md

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ interface Row {
105105
title: string;
106106
}
107107

108-
const columns: Column<Row>[] = [
108+
const columns: readonly Column<Row>[] = [
109109
{ key: 'id', name: 'ID' },
110110
{ key: 'title', name: 'Title' }
111111
];
112112

113-
const rows: Row[] = [
113+
const rows: readonly Row[] = [
114114
{ id: 0, title: 'Example' },
115115
{ id: 1, title: 'Demo' }
116116
];
@@ -591,28 +591,6 @@ test('grid', async () => {
591591

592592
###### `groupIdGetter?: Maybe<(groupKey: string, parentId?: string) => string>`
593593

594-
#### `textEditor`
595-
596-
The default text editor component for editing cells.
597-
598-
##### Props
599-
600-
`RenderEditCellProps<TRow, TSummaryRow>` - See the Types section below.
601-
602-
**Example:**
603-
604-
```tsx
605-
import { textEditor } from 'react-data-grid';
606-
607-
const columns: Column<Row>[] = [
608-
{
609-
key: 'title',
610-
name: 'Title',
611-
renderEditCell: textEditor
612-
}
613-
];
614-
```
615-
616594
#### `<Row />`
617595

618596
The default row component. Can be wrapped via the `renderers.renderRow` prop.
@@ -738,7 +716,7 @@ The default header cell renderer. Renders sortable columns with sort indicators.
738716
```tsx
739717
import { renderHeaderCell } from 'react-data-grid';
740718

741-
const columns: Column<Row>[] = [
719+
const columns: readonly Column<Row>[] = [
742720
{
743721
key: 'name',
744722
name: 'Name',
@@ -748,6 +726,24 @@ const columns: Column<Row>[] = [
748726
];
749727
```
750728

729+
#### `textEditor<TRow, TSummaryRow>(props: RenderEditCellProps<TRow, TSummaryRow>): ReactElement`
730+
731+
The default text editor for editing cells. Returns a text input element.
732+
733+
**Example:**
734+
735+
```tsx
736+
import { textEditor } from 'react-data-grid';
737+
738+
const columns: readonly Column<Row>[] = [
739+
{
740+
key: 'title',
741+
name: 'Title',
742+
renderEditCell: textEditor
743+
}
744+
];
745+
```
746+
751747
#### `renderSortIcon(props: RenderSortIconProps): ReactNode`
752748

753749
Renders the sort direction arrow icon.
@@ -801,7 +797,7 @@ Renders the expand/collapse toggle for grouped rows.
801797
```tsx
802798
import { renderToggleGroup } from 'react-data-grid';
803799

804-
const columns: Column<Row>[] = [
800+
const columns: readonly Column<Row>[] = [
805801
{
806802
key: 'group',
807803
name: 'Group',
@@ -819,7 +815,7 @@ A simple cell renderer that displays the cell value as text.
819815
```tsx
820816
import { renderValue } from 'react-data-grid';
821817

822-
const columns: Column<Row>[] = [
818+
const columns: readonly Column<Row>[] = [
823819
{
824820
key: 'title',
825821
name: 'Title',
@@ -857,7 +853,7 @@ A pre-configured column for row selection. Includes checkbox renderers for heade
857853
```tsx
858854
import { DataGrid, SelectColumn } from 'react-data-grid';
859855

860-
const columns = [SelectColumn, ...otherColumns];
856+
const columns: readonly Column<Row>[] = [SelectColumn, ...otherColumns];
861857

862858
function MyGrid() {
863859
return (
@@ -966,7 +962,7 @@ Function to determine how many columns this cell should span. Returns the number
966962
**Example:**
967963

968964
```tsx
969-
const columns: Column<Row>[] = [
965+
const columns: readonly Column<Row>[] = [
970966
{
971967
key: 'title',
972968
name: 'Title',
@@ -1081,7 +1077,7 @@ interface ColumnGroup<R, SR = unknown> {
10811077
**Example:**
10821078

10831079
```tsx
1084-
const columns = [
1080+
const columns: readonly ColumnOrColumnGroup<Row>[] = [
10851081
{
10861082
name: 'Personal Info',
10871083
children: [
@@ -1425,7 +1421,7 @@ type ColSpanArgs<TRow, TSummaryRow> =
14251421
**Example:**
14261422

14271423
```tsx
1428-
const columns: Column<Row>[] = [
1424+
const columns: readonly Column<Row>[] = [
14291425
{
14301426
key: 'title',
14311427
name: 'Title',

0 commit comments

Comments
 (0)