From 8146b8488060bbf09bf4a7417d108e48e88c906d Mon Sep 17 00:00:00 2001 From: Mert Sincan Date: Wed, 8 Jan 2025 14:35:50 +0000 Subject: [PATCH] refactor: #7049 --- packages/forms/src/useform/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/forms/src/useform/index.js b/packages/forms/src/useform/index.js index b4527b8db..481f3a989 100644 --- a/packages/forms/src/useform/index.js +++ b/packages/forms/src/useform/index.js @@ -70,6 +70,12 @@ export const useForm = (options = {}) => { }; const defineField = (field, fieldOptions) => { + if (!field) { + console.warn('The `name` attribute is required for the field definition.'); + + return []; // prevent errors + } + fields[field]?._watcher.stop(); states[field] ||= getInitialState(field, fieldOptions?.initialValue);