Skip to content

Commit 93cb1d6

Browse files
committed
[Doc] Better explain the type of getSource and scopedFormData in <FormDataConsumer>
1 parent 312867b commit 93cb1d6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

docs/Inputs.md

+2
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@ const PostEdit = () => (
542542
);
543543
```
544544

545+
**Tip:** TypeScript users will notice that `scopedFormData` and `getSource` are typed as optional parameters. This is because the `<FormDataConsumer>` component can be used outside of an `<ArrayInput>` and in that case, these parameters will be `undefined`. If you are inside an `<ArrayInput>`, you can safely assume that these parameters will be defined.
546+
545547
## Hiding Inputs Based On Other Inputs
546548

547549
You may want to display or hide inputs based on the value of another input - for instance, show an `email` input only if the `hasEmail` boolean input has been ticked to `true`.

docs/SimpleFormIterator.md

+2
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ const PostEdit = () => (
153153
);
154154
```
155155

156+
**Tip:** TypeScript users will notice that `scopedFormData` and `getSource` are typed as optional parameters. This is because the `<FormDataConsumer>` component can be used outside of a `<SimpleFormIterator>` and in that case, these parameters will be `undefined`. If you are inside a `<SimpleFormIterator>`, you can safely assume that these parameters will be defined.
157+
156158
**Note**: `<SimpleFormIterator>` only accepts `Input` components as children. If you want to use some `Fields` instead, you have to use a `<FormDataConsumer>`, as follows:
157159

158160
```jsx

0 commit comments

Comments
 (0)