fix(ui): wrong form initial values
This commit is contained in:
14
ui/src/hooks/useAntdFormName.ts
Normal file
14
ui/src/hooks/useAntdFormName.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { useCreation } from "ahooks";
|
||||
import { type FormInstance } from "antd";
|
||||
|
||||
export interface UseAntdFormNameOptions<T extends NonNullable<unknown> = any> {
|
||||
form: FormInstance<T>;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
const useAntdFormName = <T extends NonNullable<unknown> = any>(options: UseAntdFormNameOptions<T>) => {
|
||||
const formName = useCreation(() => `${options.name}_${Math.random().toString(36).substring(2, 10)}${new Date().getTime()}`, [options.name, options.form]);
|
||||
return formName;
|
||||
};
|
||||
|
||||
export default useAntdFormName;
|
||||
Reference in New Issue
Block a user