Skip to content

Commit e7d40a7

Browse files
committed
Document authLoading property of Create and CreateBase.
1 parent 4763556 commit e7d40a7

File tree

3 files changed

+50
-19
lines changed

3 files changed

+50
-19
lines changed

docs/Create.md

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,24 @@ export default App;
5555

5656
You can customize the `<Create>` component using the following props:
5757

58-
| Prop | Required | Type | Default | Description |
59-
|---------------------|----------|---------------------|----------------|--------------------------------------------------------------------------------------------------|
60-
| `children` | Optional&nbsp;* | `ReactNode` | - | The components that render the form |
61-
| `render` | Optional&nbsp;* | `function` | - | Alternative to children. Function that renders the form, receives the create context as argument |
62-
| `actions` | Optional | `ReactNode` | Default toolbar| Override the actions toolbar with a custom component |
63-
| `aside` | Optional | `ReactNode` | - | Component to render aside to the main content |
64-
| `className` | Optional | `string` | - | Passed to the root component |
65-
| `component` | Optional | `string`/`Component`| `Card` | Override the root component |
66-
| `disableAuthentication` | Optional | `boolean` | `false` | Disable the authentication check |
67-
| `mutationMode` | Optional | `string` | `pessimistic` | Switch to optimistic or undoable mutations |
68-
| `mutationOptions` | Optional | `object` | - | Options for the `dataProvider.create()` call |
69-
| `record` | Optional | `object` | `{}` | Initialize the form with a record |
70-
| `redirect` | Optional | `string`/`function` | `'edit'` | Change the redirect location after successful creation |
71-
| `resource` | Optional | `string` | From URL | Override the name of the resource to create |
72-
| `sx` | Optional | `object` | - | Override the styles |
73-
| `title` | Optional | `string`/`ReactNode`| Translation | Override the page title |
74-
| `transform` | Optional | `function` | - | Transform the form data before calling `dataProvider.create()` |
58+
| Prop | Required | Type | Default | Description |
59+
|-------------------------|-----------------|----------------------|-----------------|--------------------------------------------------------------------------------------------------|
60+
| `authLoading` | Optional | `ReactNode` | - | The component to display while checking for authentication |
61+
| `children` | Optional&nbsp;* | `ReactNode` | - | The components that render the form |
62+
| `render` | Optional&nbsp;* | `function` | - | Alternative to children. Function that renders the form, receives the create context as argument |
63+
| `actions` | Optional | `ReactNode` | Default toolbar | Override the actions toolbar with a custom component |
64+
| `aside` | Optional | `ReactNode` | - | Component to render aside to the main content |
65+
| `className` | Optional | `string` | - | Passed to the root component |
66+
| `component` | Optional | `string`/`Component` | `Card` | Override the root component |
67+
| `disableAuthentication` | Optional | `boolean` | `false` | Disable the authentication check |
68+
| `mutationMode` | Optional | `string` | `pessimistic` | Switch to optimistic or undoable mutations |
69+
| `mutationOptions` | Optional | `object` | - | Options for the `dataProvider.create()` call |
70+
| `record` | Optional | `object` | `{}` | Initialize the form with a record |
71+
| `redirect` | Optional | `string`/`function` | `'edit'` | Change the redirect location after successful creation |
72+
| `resource` | Optional | `string` | From URL | Override the name of the resource to create |
73+
| `sx` | Optional | `object` | - | Override the styles |
74+
| `title` | Optional | `string`/`ReactNode` | Translation | Override the page title |
75+
| `transform` | Optional | `function` | - | Transform the form data before calling `dataProvider.create()` |
7576

7677
`*` You must provide either `children` or `render`.
7778

@@ -125,6 +126,20 @@ const PostCreate = () => (
125126

126127
{% endraw %}
127128

129+
## `authLoading`
130+
131+
By default, `<Create>` renders the children while checking for authentication and permissions. You can display a component during this time via the `authLoading` prop:
132+
133+
```jsx
134+
import { Create } from 'react-admin';
135+
136+
export const PostCreate = () => (
137+
<Create authLoading={<p>Checking for permissions...</p>}>
138+
...
139+
</Create>
140+
);
141+
```
142+
128143
## `children`
129144

130145
The `<Create>` component will render its children inside a [`CreateContext`](./useCreateContext.md#return-value). Children can be any React node, but are usually a form component like [`<SimpleForm>`](./SimpleForm.md), [`<TabbedForm>`](./TabbedForm.md), or the headless [`<Form>`](./Form.md) component.

docs/CreateBase.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ export const BookCreate = () => (
4545

4646
You can customize the `<CreateBase>` component using the following props, documented in the `<Create>` component:
4747

48-
* `children`: the components that renders the form
49-
* `render`: alternative to children, a function that takes the `CreateController` context and renders the form
48+
* [`authLoading`](./Create.md#authloading): the component to display while checking for authentication
49+
* [`children`](./Create.md#children): the components that renders the form
50+
* [`render`](./Create.md#render): alternative to children, a function that takes the `CreateController` context and renders the form
5051
* [`disableAuthentication`](./Create.md#disableauthentication): disable the authentication check
5152
* [`mutationMode`](./Create.md#mutationmode): Switch to optimistic or undoable mutations (pessimistic by default)
5253
* [`mutationOptions`](./Create.md#mutationoptions): options for the `dataProvider.create()` call

docs_headless/src/content/docs/CreateBase.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const BookCreate = () => (
4040

4141
You can customize the `<CreateBase>` component using the following props:
4242

43+
* [`authLoading`](#authloading): the component to display while checking for authentication
4344
* [`children`](#children): the components that renders the form
4445
* [`render`](#render): alternative to children, a function that takes the `CreateController` context and renders the form
4546
* [`disableAuthentication`](#disableauthentication): disable the authentication check
@@ -50,6 +51,20 @@ You can customize the `<CreateBase>` component using the following props:
5051
* [`resource`](#resource): override the name of the resource to create
5152
* [`transform`](#transform): transform the form data before calling `dataProvider.create()`
5253

54+
## `authLoading`
55+
56+
By default, `<CreateBase>` renders the children while checking for authentication and permissions. You can display a component during this time via the `authLoading` prop:
57+
58+
```jsx
59+
import { CreateBase } from 'ra-core';
60+
61+
export const PostCreate = () => (
62+
<CreateBase authLoading={<p>Checking for permissions...</p>}>
63+
...
64+
</CreateBase>
65+
);
66+
```
67+
5368
## `children`
5469

5570
The `<CreateBase>` component will render its children inside a [`CreateContext`](./useCreateContext.md#return-value). Children can be any React node, but are usually a form component like the headless [`<Form>`](./Form.md) component.

0 commit comments

Comments
 (0)