Skip to content

Commit 324c0d7

Browse files
Fix(recordRepresentation): Allow ReactNode
1 parent b60e770 commit 324c0d7

File tree

6 files changed

+7
-13
lines changed

6 files changed

+7
-13
lines changed

docs/AutocompleteInput.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ The form value for the source must be the selected value, e.g.
7070
| `offline` | Optional | `ReactNode` | - | What to render when there is no network connectivity when fetching the choices |
7171
| `onChange` | Optional | `Function` | `-` | A function called with the new value, along with the selected record, when the input value changes |
7272
| `onCreate` | Optional | `Function` | `-` | A function called with the current filter value when users choose to create a new choice. |
73-
| `optionText` | Optional | `string` | `Function` | `Component` | `undefined` | `record Representation` | Field name of record to display in the suggestion item or function using the choice object as argument |
73+
| `optionText` | Optional | `function` | `ReactNode` | `undefined` | `record Representation` | Field name of record to display in the suggestion item or function using the choice object as argument |
7474
| `optionValue` | Optional | `string` | `id` | Field name of record containing the value to use as input value |
7575
| `setFilter` | Optional | `Function` | `null` | A callback to inform the `searchText` has changed and new `choices` can be retrieved based on this `searchText`. Signature `searchText => void`. This function is automatically set up when using `ReferenceInput`. |
7676
| `shouldRender Suggestions` | Optional | `Function` | `() => true` | A function that returns a `boolean` to determine whether or not suggestions are rendered. |

docs/Resource.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ The routes call the following `dataProvider` methods:
6565
| `create` | | `React.ComponentType` | - | The component to render for the create view |
6666
| `edit` | | `React.ComponentType` | - | The component to render for the edit view |
6767
| `show` | | `React.ComponentType` | - | The component to render for the show view |
68-
| `record Representation` | | `string` or `function` or `React.ComponentType` | - | The representation of a record to use in the UI |
68+
| `record Representation` | | `function` | `ReactNode` | - | The representation of a record to use in the UI |
6969
| `icon` | | `React.ComponentType` | - | The component to render in the menu |
7070
| `options` | | `object` | - | Additional options for the resource |
7171
| `children` | | `Route` | - | Sub-routes for the resource |

docs/SelectInput.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The form value for the source must be the selected value, e.g.
6666
| `emptyValue` | Optional | `any` | '' | The value to use for the empty option |
6767
| `isPending` | Optional | `boolean` | `false` | If `true`, the component will display a loading indicator. |
6868
| `onCreate` | Optional | `Function` | `-` | A function called with the current filter value when users choose to create a new choice. |
69-
| `optionText` | Optional | `string` | `Function` | `Component` | `undefined` | `record Representation` | Field name of record to display in the suggestion item or function using the choice object as argument |
69+
| `optionText` | Optional | `function` | `ReactNode` | `undefined` | `record Representation` | Field name of record to display in the suggestion item or function using the choice object as argument |
7070
| `optionValue` | Optional | `string` | `id` | Field name of record containing the value to use as input value |
7171
| `resettable` | Optional | `boolean` | `false` | If `true`, display a button to reset the changes in this input value |
7272
| `translateChoice` | Optional | `boolean` | `true` | Whether the choices should be translated |

docs_headless/src/content/docs/Resource.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The routes call the following `dataProvider` methods:
6363
| `create` | | `React.ComponentType` | - | The component to render for the create view |
6464
| `edit` | | `React.ComponentType` | - | The component to render for the edit view |
6565
| `show` | | `React.ComponentType` | - | The component to render for the show view |
66-
| `record Representation` | | `string` or `function` or `React.ComponentType` | - | The representation of a record to use in the UI |
66+
| `record Representation` | | `function` | `ReactNode` | - | The representation of a record to use in the UI |
6767
| `icon` | | `React.ComponentType` | - | The component to render in the menu |
6868
| `options` | | `object` | - | Additional options for the resource |
6969
| `children` | | `Route` | - | Sub-routes for the resource |

packages/ra-core/src/core/useResourceDefinition.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,5 @@ export interface UseResourceDefinitionOptions {
7171
readonly hasEdit?: boolean;
7272
readonly hasShow?: boolean;
7373
readonly hasCreate?: boolean;
74-
readonly recordRepresentation?:
75-
| string
76-
| React.ReactElement
77-
| RecordToStringFunction;
74+
readonly recordRepresentation?: React.ReactNode | RecordToStringFunction;
7875
}

packages/ra-core/src/types.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,7 @@ export interface ResourceDefinition<OptionsType extends ResourceOptions = any> {
318318
readonly hasShow?: boolean;
319319
readonly hasCreate?: boolean;
320320
readonly icon?: any;
321-
readonly recordRepresentation?:
322-
| ReactElement
323-
| RecordToStringFunction
324-
| string;
321+
readonly recordRepresentation?: React.ReactNode | RecordToStringFunction;
325322
}
326323

327324
/**
@@ -385,7 +382,7 @@ export interface ResourceProps {
385382
hasEdit?: boolean;
386383
hasShow?: boolean;
387384
icon?: ComponentType<any>;
388-
recordRepresentation?: ReactElement | RecordToStringFunction | string;
385+
recordRepresentation?: React.ReactNode | RecordToStringFunction;
389386
options?: ResourceOptions;
390387
children?: ReactNode;
391388
}

0 commit comments

Comments
 (0)