We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 727c52f + 861629c commit 4078423Copy full SHA for 4078423
src/use-form.js
@@ -228,10 +228,14 @@ export default function useNewForm(fieldConfig) {
228
return formValues[fieldName];
229
},
230
get errorMsg() {
231
- return formErrors[fieldName].errorMsg;
+ return formErrors[fieldName]?.errorMsg ?? '';
232
233
get isValid() {
234
- return formErrors[fieldName].isValid;
+ /**
235
+ * Validation happens async, so there is a possibility that `formErrors[fieldName]` is not defined yet.
236
+ * So by default, for that duration isValid is false
237
+ */
238
+ return formErrors[fieldName]?.isValid ?? false;
239
240
};
241
});
0 commit comments