From be472b5963f2044a57d4eb6d3c5084fe4a83cc87 Mon Sep 17 00:00:00 2001 From: Elvis Liao Date: Tue, 5 Nov 2024 19:38:51 +0800 Subject: [PATCH] fix(Form): fixed an issue when form-item is used out of form(#3182) --- src/form/hooks/useFormItemInitialData.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/form/hooks/useFormItemInitialData.ts b/src/form/hooks/useFormItemInitialData.ts index 2e8908314c..9ff275729a 100644 --- a/src/form/hooks/useFormItemInitialData.ts +++ b/src/form/hooks/useFormItemInitialData.ts @@ -56,7 +56,7 @@ export default function useFormItemInitialData(name: FormItemProps['name']) { children: FormItemProps['children']; initialData: FormItemProps['initialData']; }) { - if (name && !isEmpty(floatingFormDataRef.current)) { + if (name && floatingFormDataRef?.current && !isEmpty(floatingFormDataRef.current)) { const nameList = formListName ? [formListName, name].flat() : name; const defaultInitialData = get(floatingFormDataRef.current, nameList); if (typeof defaultInitialData !== 'undefined') {