Skip to content

Commit

Permalink
Applied review
Browse files Browse the repository at this point in the history
  • Loading branch information
WiXSL committed Sep 22, 2022
1 parent 94836c1 commit 6f80a9f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
22 changes: 2 additions & 20 deletions docs/Inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ import { FormDataConsumer } from 'react-admin';

const PostEdit = () => (
<Edit>
<SimpleForm>
<SimpleForm shouldUnregister>
<BooleanInput source="hasEmail" />
<FormDataConsumer>
{({ formData, ...rest }) => formData.hasEmail &&
Expand All @@ -522,25 +522,7 @@ import { FormDataConsumer } from 'react-admin';
);
```

**Important**: By default `react-hook-form` submits values of unmounted input components, so if you don't want this behaivour you can set `shouldUnregister` prop to `true` in the form

```diff
import { FormDataConsumer } from 'react-admin';

const PostEdit = () => (
<Edit>
- <SimpleForm>
+ <SimpleForm shouldUnregister>
<BooleanInput source="hasEmail" />
<FormDataConsumer>
{({ formData, ...rest }) => formData.hasEmail &&
<TextInput source="email" {...rest} />
}
</FormDataConsumer>
</SimpleForm>
</Edit>
);
```
**Important**: By default `react-hook-form` submits values of unmounted input components, to prevent this from happen in the above example, `shouldUnregister` prop was set to `true` in the `<SimpleForm>`

## Overriding The Input Variant

Expand Down
2 changes: 1 addition & 1 deletion docs/ListBase.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ The `<ListBase>` component accepts the same props as [`useListController`](./use
* [`resource`](./List.md#resource)
* [`sort`](./List.md#sort-default-sort-field--order)

These are a subset of the props accepted by `<List>` - only the props that change data fetching, and not the props related to the user interface.
These are a subset of the props accepted by `<List>` - only the props that change data fetching, and not the props related to the user interface.

0 comments on commit 6f80a9f

Please sign in to comment.