Skip to content

Commit 945ab5c

Browse files
[Chore]: Update ra-core to use ReactNode instead of ReactElement where applicable
1 parent c27492d commit 945ab5c

19 files changed

+46
-51
lines changed

docs_headless/src/content/docs/DeletedRecordsListBase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ That's enough to display the deleted records list, with functional simple filter
5959

6060
| Prop | Required | Type | Default | Description |
6161
|----------------------------|----------------|---------------------------------|------------------------------------------|--------------------------------------------------------------------------------------------------|
62-
| `children` | Required | `Element` | | The component used to render the list of deleted records. |
62+
| `children` | Required | `ReactNode` | | The component used to render the list of deleted records. |
6363
| `authLoading` | Optional | `ReactNode` | - | The component to render while checking for authentication and permissions. |
6464
| `debounce` | Optional | `number` | `500` | The debounce delay in milliseconds to apply when users change the sort or filter parameters. |
6565
| `disable Authentication` | Optional | `boolean` | `false` | Set to `true` to disable the authentication check. |

docs_headless/src/content/docs/ReferenceArrayFieldBase.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ You can change how the list of related records is rendered by passing a custom c
8383
| -------------- | -------- | --------------------------------------------------------------------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------ |
8484
| `source` | Required | `string` | - | Name of the property to display |
8585
| `reference` | Required | `string` | - | The name of the resource for the referenced records, e.g. 'tags' |
86-
| `children` | Optional\* | `Element` | | One or several elements that render a list of records based on a `ListContext` |
87-
| `render` | Optional\* | `(ListContext) => Element` | | A function that takes a list context and renders a list of records |
86+
| `children` | Optional\* | `ReactNode` | | One or several elements that render a list of records based on a `ListContext` |
87+
| `render` | Optional\* | `(ListContext) => ReactNode` | | A function that takes a list context and renders a list of records |
8888
| `empty` | Optional | `ReactNode` | - | The component to render when the related records list is empty |
8989
| `error` | Optional | `ReactNode` | - | The component to render when an error occurs while fetching the related records |
9090
| `filter` | Optional | `Object` | - | Filters to use when fetching the related records (the filtering is done client-side) |

docs_headless/src/content/docs/ReferenceManyFieldBase.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ export const PostList = () => (
8888
| -------------- | -------- | --------------------------------------------------------------------------------- | -------------------------------- | ----------------------------------------------------------------------------------- |
8989
| `reference` | Required | `string` | - | The name of the resource for the referenced records, e.g. 'books' |
9090
| `target` | Required | `string` | - | Target field carrying the relationship on the referenced resource, e.g. 'user_id' |
91-
| `children` | Optional\* | `Element` | - | One or several elements that render a list of records based on a `ListContext` |
92-
| `render` | Optional\* | `(ListContext) => Element` | - | Function that receives a `ListContext` and returns an element |
91+
| `children` | Optional\* | `ReactNode` | - | One or several elements that render a list of records based on a `ListContext` |
92+
| `render` | Optional\* | `(ListContext) => ReactNode` | - | Function that receives a `ListContext` and returns an element |
9393
| `debounce` | Optional | `number` | 500 | debounce time in ms for the `setFilters` callbacks |
9494
| `empty` | Optional | `ReactNode` | - | Element to display when there are no related records. |
9595
| `error` | Optional | `ReactNode` | - | The component to render when an error occurs while fetching the related records |

docs_headless/src/content/docs/ReferenceManyInputBase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const ProductEdit = () => (
6868
| ----------------- | -------- | ------------------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
6969
| `target` | Required | `string` | - | Target field carrying the relationship on the referenced resource, e.g. 'user_id' |
7070
| `reference` | Required | `string` | - | The name of the resource for the referenced records, e.g. 'books' |
71-
| `children` | Optional | `Element` | - | One or several elements that render a list of records based on a `ListContext` |
71+
| `children` | Optional | `ReactNode` | - | One or several elements that render a list of records based on a `ListContext` |
7272
| `defaultValue` | Optional | `array` | - | Default value of the input. |
7373
| `filter` | Optional | `Object` | - | Filters to use when fetching the related records, passed to `getManyReference()` |
7474
| `mutationOptions` | Optional | `UseMutationOptions` | - | Options for the mutations (`create`, `update` and `delete`) |

docs_headless/src/content/docs/ReferenceOneFieldBase.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ const BookDetails = () => {
6969
| -------------- | ---------- | -------------------------------------------------------------------------------- | ------------------------------- | --------------------------------------------------------------------------------- |
7070
| `reference` | Required | `string` | - | The name of the resource for the referenced records, e.g. 'book_details' |
7171
| `target` | Required | string | - | Target field carrying the relationship on the referenced resource, e.g. 'book_id' |
72-
| `children` | Optional\* | `Element` | - | React component to render the referenced record. |
73-
| `render` | Optional\* | `(ReferenceFieldContext) => Element` | - | A function that takes the `ReferenceFieldContext` and return a React element |
72+
| `children` | Optional\* | `ReactNode` | - | React component to render the referenced record. |
73+
| `render` | Optional\* | `(ReferenceFieldContext) => ReactNode` | - | A function that takes the `ReferenceFieldContext` and return a React element |
7474
| `empty` | Optional | `ReactNode` | - | The text or element to display when the referenced record is empty |
7575
| `filter` | Optional | `Object` | `{}` | Used to filter referenced records |
7676
| `link` | Optional | `string | Function` | `edit` | Target of the link wrapping the rendered child. Set to `false` to disable the link. |

docs_headless/src/content/docs/ReferenceOneInputBase.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ const BookEdit = () => (
5656
| ----------------- | -------- | -------------------- | ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5757
| `target` | Required | `string` | - | Target field carrying the relationship on the referenced resource, e.g. 'book_id' |
5858
| `reference` | Required | `string` | - | The name of the resource for the referenced records, e.g. 'book_details' |
59-
| `children` | Optional | `Element` | - | One or several input elements that accept a `source` prop |
59+
| `children` | Optional | `ReactNode` | - | One or several input elements that accept a `source` prop |
6060
| `defaultValue` | Optional | `Object` | - | Default value for the related record (in case it does not yet exist) |
61-
| `error` | Optional | `Element` | - | The element to display when an error occurs while loading a reference |
61+
| `error` | Optional | `ReactNode` | - | The element to display when an error occurs while loading a reference |
6262
| `filter` | Optional | `Object` | - | Filters to use when fetching the related record, passed to `getManyReference() |
63-
| `loading` | Optional | `Element` | - | The element to display while loading a reference |
63+
| `loading` | Optional | `ReactNode` | - | The element to display while loading a reference |
6464
| `mutationOptions` | Optional | `UseMutationOptions` | - | Options for the mutations (`create` and `update`) |
6565
| `render` | Optional | `Function` | - | A function that returns the children to display. Takes precedence over `children` |
6666
| `sort` | Optional | `{ field, order }` | `{ field: 'id', order: 'ASC' }` | Sort order to use when fetching the related record, passed to `getManyReference() |

docs_headless/src/content/docs/ShowDeletedBase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,5 @@ const DeletedItem = ({ record }: { record: DeletedRecordType }) => {
7474

7575
| Prop | Required | Type | Default | Description |
7676
|------------|----------|------------|---------|---------------------------------------------------------------------------------------|
77-
| `children` | Required | `Element` | | The component used to render the deleted record. |
77+
| `children` | Required | `ReactNode` | | The component used to render the deleted record. |
7878
| `record` | Optional | `RaRecord` | | The deleted record. If not provided, the record from closest `RecordContext` is used. |

packages/ra-core/src/auth/WithPermissions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { Children, ReactElement, ComponentType, createElement } from 'react';
2+
import { Children, ComponentType, createElement } from 'react';
33
import { Location } from 'react-router-dom';
44

55
import warning from '../util/warning';
@@ -12,7 +12,7 @@ export interface WithPermissionsChildrenParams {
1212

1313
type WithPermissionsChildren = (
1414
params: WithPermissionsChildrenParams
15-
) => ReactElement;
15+
) => React.ReactNode;
1616

1717
export interface WithPermissionsProps {
1818
authParams?: object;

packages/ra-core/src/controller/field/ReferenceArrayFieldBase.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { type ReactElement, type ReactNode } from 'react';
2+
import { type ReactNode } from 'react';
33

44
import type { UseQueryOptions } from '@tanstack/react-query';
55
import { FilterPayload, RaRecord, SortPayload } from '../../types';
@@ -170,7 +170,7 @@ export interface ReferenceArrayFieldBaseProps<
170170
ReferenceRecordType extends RaRecord = RaRecord,
171171
> extends BaseFieldProps<RecordType> {
172172
children?: ReactNode;
173-
render?: (props: ListControllerResult<ReferenceRecordType>) => ReactElement;
173+
render?: (props: ListControllerResult<ReferenceRecordType>) => ReactNode;
174174
error?: ReactNode;
175175
loading?: ReactNode;
176176
empty?: ReactNode;

packages/ra-core/src/controller/record/OptionalRecordContextProvider.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { ReactElement } from 'react';
32
import { RaRecord } from '../../types';
43
import { RecordContextProvider } from './RecordContext';
54

@@ -24,7 +23,7 @@ export const OptionalRecordContextProvider = <
2423
value,
2524
children,
2625
}: {
27-
children: ReactElement;
26+
children: React.ReactNode;
2827
value?: RecordType;
2928
}) =>
3029
value ? (

0 commit comments

Comments
 (0)