fix(ui): wrong form initial values

This commit is contained in:
Fu Diwei
2025-01-05 00:47:27 +08:00
parent 61843a4997
commit ddb6a88392
12 changed files with 38 additions and 29 deletions

View 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;