Skip to content

Commit b718465

Browse files
Chore: Use ReactNode instead of ReactElement where applicable
1 parent 05383e9 commit b718465

39 files changed

+110
-116
lines changed

docs/CheckForApplicationUpdate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const App = () => (
4646
| --------------- | -------- | -------------- | ------------------ |-------------------------------------------------------------------- |
4747
| `interval` | Optional | `number` | `3600000` (1 hour) | The interval in milliseconds between two checks |
4848
| `disabled` | Optional | `boolean` | `false` | Whether the automatic check is disabled |
49-
| `notification` | Optional | `ReactElement` | | The notification to display to the user when an update is available |
49+
| `notification` | Optional | `ReactNode` | | The notification to display to the user when an update is available |
5050
| `onNewVersion Available` | Optional | `function` | | The effect to execute when a new version is detected. |
5151
| `url` | Optional | `string` | Current URL | The URL to download to check for code update |
5252
| `fetchOptions` | Optional | `RequestInit | undefined` | `undefined` | The options passed to `fetch` when checking for an update |

docs/Create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ You can customize the `<Create>` component using the following props:
7171
| `redirect` | Optional | `string`/`function` | `'edit'` | Change the redirect location after successful creation |
7272
| `resource` | Optional | `string` | From URL | Override the name of the resource to create |
7373
| `sx` | Optional | `object` | - | Override the styles |
74-
| `title` | Optional | `string`/`ReactNode` | Translation | Override the page title |
74+
| `title` | Optional | `ReactNode` | Translation | Override the page title |
7575
| `transform` | Optional | `function` | - | Transform the form data before calling `dataProvider.create()` |
7676

7777
`*` You must provide either `children` or `render`.

docs/Datagrid.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ Both are [Enterprise Edition](https://react-admin-ee.marmelab.com) components.
5050

5151
| Prop | Required | Type | Default | Description |
5252
| -------------------- | -------- | ----------------------- | --------------------- | ------------------------------------------------------------- |
53-
| `children` | Required | Element | n/a | The list of `<Field>` components to render as columns. |
54-
| `body` | Optional | Element | `<Datagrid Body>` | The component used to render the body of the table. |
55-
| `bulkActionButtons` | Optional | Element | `<BulkDelete Button>` | The component used to render the bulk action buttons. |
56-
| `empty` | Optional | Element | `<Empty>` | The component used to render the empty table. |
57-
| `expand` | Optional | Element | | The component used to render the expand panel for each row. |
53+
| `children` | Required | `ReactNode` | n/a | The list of `<Field>` components to render as columns. |
54+
| `body` | Optional | `ReactNode` | `<Datagrid Body>` | The component used to render the body of the table. |
55+
| `bulkActionButtons` | Optional | `ReactNode` | `<BulkDelete Button>` | The component used to render the bulk action buttons. |
56+
| `empty` | Optional | `ReactNode` | `<Empty>` | The component used to render the empty table. |
57+
| `expand` | Optional | `ReactElement` | | The component used to render the expand panel for each row. |
5858
| `expandSingle` | Optional | Boolean | `false` | Whether to allow only one expanded row at a time. |
59-
| `header` | Optional | Element | `<Datagrid Header>` | The component used to render the table header. |
59+
| `header` | Optional | `ReactNode` | `<Datagrid Header>` | The component used to render the table header. |
6060
| `hover` | Optional | Boolean | `true` | Whether to highlight the row under the mouse. |
6161
| `isRowExpandable` | Optional | Function | `() => true` | A function that returns whether a row is expandable. |
6262
| `isRowSelectable` | Optional | Function | `() => true` | A function that returns whether a row is selectable. |

docs/FilterList.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ A more sophisticated example is the filter sidebar for the visitors list visible
7777
|------|----------|------|---------|-------------|
7878
| [`children`](#children) | Required | node | | The children of `<FilterList>` must be a list of `<FilterListItem>` components. |
7979
| [`icon`](#icon) | Optional | element | | When set, the `<FilterList icon>` prop appears on the left side of the filter label. |
80-
| [`label`](#label) | Optional | string | | React-admin renders the `<FilterList label>` on top of the child filter items. The string is passed through the `useTranslate` hook, and therefore can be translated. |
80+
| [`label`](#label) | Optional | `ReactNode` | | React-admin renders the `<FilterList label>` on top of the child filter items. The string is passed through the `useTranslate` hook, and therefore can be translated. |
8181

8282
## `children`
8383

@@ -274,7 +274,7 @@ The children of `<FilterList>` must be a list of `<FilterListItem>` components.
274274

275275
| Prop | Required | Type | Default | Description |
276276
|------|----------|------|---------|-------------|
277-
| `label` | Required | string | | The label of the filter item. It is passed through the `useTranslate` hook, and therefore can be translated. |
277+
| `label` | Required | `ReactNode` | | The label of the filter item. It is passed through the `useTranslate` hook, and therefore can be translated. |
278278
| `value` | Required | object | | The value of the filter item. It is merged with the current filter value when enabled by the user. |
279279
| `icon` | Optional | `ReactElement` | | When set, the icon appears to the left of the item label. |
280280
| `isSelected` | Optional | function | | A function that receives the item value and the currently applied filters. It must return a boolean. |
@@ -372,4 +372,4 @@ export const BookList = () => (
372372

373373
![FilterLiveForm](./img/FilterLiveForm.png)
374374

375-
Check out the [`<FilterLiveForm>` documentation](./FilterLiveForm.md) for more information.
375+
Check out the [`<FilterLiveForm>` documentation](./FilterLiveForm.md) for more information.

docs/List.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ You can find more advanced examples of `<List>` usage in the [demos](./Demos.md)
5858
| `children` | Optional&nbsp;* | `ReactNode` | - | The components rendering the list of records. |
5959
| `render` | Optional&nbsp;* | `(listContext) => ReactNode` | - | A function to render the list of records. Receive the list context as its argument |
6060
| `actions` | Optional | `ReactElement` | - | The actions to display in the toolbar. |
61-
| `aside` | Optional | `ReactElement` | - | The component to display on the side of the list. |
61+
| `aside` | Optional | `ReactNode` | - | The component to display on the side of the list. |
6262
| `authLoading` | Optional | `ReactNode` | - | The component to render while checking for authentication and permissions. |
6363
| `component` | Optional | `Component` | `Card` | The component to render as the root element. |
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. |
6666
| `disable SyncWithLocation` | Optional | `boolean` | `false` | Set to `true` to disable the synchronization of the list parameters with the URL. |
67-
| `empty` | Optional | `ReactElement` | - | The component to display when the list is empty. |
67+
| `empty` | Optional | `ReactNode` | - | The component to display when the list is empty. |
6868
| `empty WhileLoading` | Optional | `boolean` | `false` | Set to `true` to return `null` while the list is loading. |
6969
| `error` | Optional | `ReactNode` | - | The component to render when failing to load the list of records. |
7070
| `exporter` | Optional | `function` | - | The function to call to export the list. |
@@ -79,7 +79,7 @@ You can find more advanced examples of `<List>` usage in the [demos](./Demos.md)
7979
| `resource` | Optional | `string` | - | The resource name, e.g. `posts`. |
8080
| `sort` | Optional | `object` | - | The initial sort parameters. |
8181
| `storeKey` | Optional | `string` &#124; `false` | - | The key to use to store the current filter & sort. Pass `false` to disable store synchronization |
82-
| `title` | Optional | `string` &#124;` ReactElement` &#124; `false` | - | The title to display in the App Bar. |
82+
| `title` | Optional | `ReactNode` | - | The title to display in the App Bar. |
8383
| `sx` | Optional | `object` | - | The CSS styles to apply to the component. |
8484

8585
`*` You must provide either `children` or `render`.

docs/ReferenceOneField.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ const BookShow = () => (
5959
| -------------- | -------- | ------------------------------------------- | -------------------------------- | ----------------------------------------------------------------------------------- |
6060
| `reference` | Required | `string` | - | The name of the resource for the referenced records, e.g. 'book_details' |
6161
| `target` | Required | string | - | Target field carrying the relationship on the referenced resource, e.g. 'book_id' |
62-
| `children` | Optional&nbsp;* | `Element` | - | The Field element used to render the referenced record |
63-
| `render` | Optional&nbsp;* | `(ReferenceFieldContext) => Element` | - | A function that takes the `ReferenceFieldContext` and returns a React element |
62+
| `children` | Optional&nbsp;* | `ReactNode` | - | The Field element used to render the referenced record |
63+
| `render` | Optional&nbsp;* | `(ReferenceFieldContext) => ReactNode` | - | A function that takes the `ReferenceFieldContext` and returns a React element |
6464
| `empty` | Optional | `ReactNode` | - | The text or element to display when the referenced record is empty |
6565
| `filter` | Optional | `Object` | `{}` | Used to filter referenced records |
6666
| `link` | Optional | `string | Function` | `edit` | Target of the link wrapping the rendered child. Set to `false` to disable the link. |

docs/SimpleForm.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ Here are all the props you can set on the `<SimpleForm>` component:
3939

4040
| Prop | Required | Type | Default | Description |
4141
| ------------------------- | -------- | ------------------ | ------- | ---------------------------------------------------------- |
42-
| `children` | Required | `element` | - | The form content. |
42+
| `children` | Required | `ReactNode` | - | The form content. |
4343
| `component` | Optional | `elementType` | `CardContent` | The component used to wrap the form. |
4444
| `defaultValues` | Optional | `object| function` | - | The default values of the record. |
4545
| `id` | Optional | `string` | - | The id of the underlying `<form>` tag. |
4646
| `noValidate` | Optional | `boolean` | - | Set to `true` to disable the browser's default validation. |
4747
| `onSubmit` | Optional | `function` | `save` | A callback to call when the form is submitted. |
4848
| `sanitize EmptyValues` | Optional | `boolean` | - | Set to `true` to remove empty values from the form state. |
4949
| `sx` | Optional | `object` | - | Custom styles |
50-
| `toolbar` | Optional | `element` | - | The toolbar component. |
50+
| `toolbar` | Optional | `ReactNode` | - | The toolbar component. |
5151
| `validate` | Optional | `function` | - | A function to validate the form values. |
5252
| `warnWhen UnsavedChanges` | Optional | `boolean` | - | Set to `true` to warn the user when leaving the form with unsaved changes. |
5353

docs/SimpleList.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ export const PostList = () => (
4242

4343
| Prop | Required | Type | Default | Description |
4444
| --- | --- | --- | --- | --- |
45-
| `primaryText` | Optional | mixed | record representation | The primary text to display. |
46-
| `secondaryText` | Optional | mixed | | The secondary text to display. |
47-
| `tertiaryText` | Optional | mixed | | The tertiary text to display. |
45+
| `primaryText` | Optional | `ReactNode` or `function` | record representation | The primary text to display. |
46+
| `secondaryText` | Optional | `ReactNode` or `function` | | The secondary text to display. |
47+
| `tertiaryText` | Optional | `ReactNode` | or `function` | The tertiary text to display. |
4848
| `rowClick` | Optional |mixed | `"edit"` | The action to trigger when the user clicks on a row. |
4949
| `leftAvatar` | Optional | function | | A function returning an `<Avatar>` component to display before the primary text. |
5050
| `leftIcon` | Optional | function | | A function returning an `<Icon>` component to display before the primary text. |
5151
| `rightAvatar` | Optional | function | | A function returning an `<Avatar>` component to display after the primary text. |
5252
| `rightIcon` | Optional | function | | A function returning an `<Icon>` component to display after the primary text. |
5353
| `rowStyle` | Optional | function | | A function returning a style object to apply to each row. |
5454
| `rowSx` | Optional | function | | A function returning a sx object to apply to each row. |
55-
| `empty` | Optional | ReactElement | | A ReactElement to display instead of the list when the data is empty. |
55+
| `empty` | Optional | `ReactNode` | | A `ReactNode` to display instead of the list when the data is empty. |
5656

5757
## `empty`
5858

examples/simple/src/users/UserList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Aside from './Aside';
1717
import UserEditEmbedded from './UserEditEmbedded';
1818
export const UserIcon = PeopleIcon;
1919

20-
const getUserFilters = (canSeeRole: boolean): React.ReactElement[] => {
20+
const getUserFilters = (canSeeRole: boolean) => {
2121
const filters = [
2222
<SearchInput source="q" alwaysOn />,
2323
<TextInput source="name" />,

packages/ra-no-code/src/ui/NewResourceMenuItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { styled } from '@mui/material/styles';
3-
import { ReactElement, useState } from 'react';
3+
import { useState } from 'react';
44
import AddIcon from '@mui/icons-material/Add';
55
import { ImportResourceDialog } from './ImportResourceDialog';
66
import {
@@ -48,7 +48,7 @@ export const NewResourceMenuItem = (
4848

4949
const primaryText = 'New resource';
5050

51-
const renderMenuItem = (): ReactElement => (
51+
const renderMenuItem = () => (
5252
<MenuItem
5353
className={classes.root}
5454
tabIndex={0}

0 commit comments

Comments
 (0)