-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(antd): useDrawerForm has unused props (#6074)
- Loading branch information
1 parent
853bef9
commit 311dcdc
Showing
9 changed files
with
313 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
"@refinedev/antd": minor | ||
--- | ||
|
||
fix: [`useDrawerForm`](https://refine.dev/docs/ui-integrations/ant-design/hooks/use-drawer-form/)'s `submit` and `form` props are not working (#6082). | ||
|
||
- `submit` prop is removed from `useDrawerForm` hook. Instead, you can use `onFinish` prop to handle the form submission. | ||
https://refine.dev/docs/guides-concepts/forms/#modifying-data-before-submission | ||
|
||
- `form` prop is removed from `useDrawerForm` hook. | ||
The purpose of `useDrawerForm` is to create a `form` instance. Because of that `form` instance cannot be passed as a prop. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
"@refinedev/antd": minor | ||
--- | ||
|
||
fix: `useForm`'s `defaultFormValues` prop is not working (#5727). | ||
|
||
From now on, `useForm`, `useDrawerForm`, and `useModalForm` hooks accept the `defaultFormValues` prop to pre-populate the form with data that needs to be displayed. | ||
|
||
```tsx | ||
useForm({ | ||
defaultFormValues: { | ||
title: "Hello World", | ||
}, | ||
}); | ||
``` | ||
|
||
Also, it can be provided as an async function to fetch the default values. The loading state can be tracked using the `defaultFormValuesLoading` state returned from the hook. | ||
|
||
> 🚨 When `action` is "edit" or "clone" a race condition with `async defaultFormValues` may occur. In this case, the form values will be the result of the last completed operation. | ||
```tsx | ||
const { defaultFormValuesLoading } = useForm({ | ||
defaultFormValues: async () => { | ||
const response = await fetch("https://my-api.com/posts/1"); | ||
const data = await response.json(); | ||
return data; | ||
}, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.