On kendo-react-form version 7.0.2, passing a validator to the Form component seems to invoke the validator function in an infinite loop.
When I render a form with the following code, my "Form Validation" console log prints to the console infinitely. It doesn't seem to be a re-render issue, as my "Form Render" console log inside of the Form's render function does not seem to get called infinitely.
The particular form validator function I'm using for the purpose of this example is taken directly from https://www.telerik.com/kendo-react-ui/components/form/validation/#toc-form-validation.
Can anyone advise me on whether this is the expected behavior, or if there is a problem with kendo-react-form 7.0.2, or if there's something obvious that I'm doing wrong in my implementation?
export const UserForm = (props: UserFormProps) => {
const handleResponse = (result: any) => {
setServerErrorState(result);
if (result.errorDetails?.length > 0 || result.errorMessage) {
onSubmitError(result);
}
else {
setServerErrorState(null);
onSubmitSuccess(result);
}
};
const firstNameGetter: any = getter("user.firstName");
const lastNameGetter: any = getter("user.lastName");
const firstOrLastNameValidator = (values: any) => {
console.log("Form Validation");
if (firstNameGetter(values) || lastNameGetter(values)) {
return;
}
return {
VALIDATION_SUMMARY: "Please fill at least one of the following fields.",
["user.firstName"]:
"Please check the validation summary for more information.",
["user.lastName"]:
"Please check the validation summary for more information.",
};
};
return (
<Form
id="test"
initialValues={props.editorUser}
onSubmitClick={handleSubmit}
validator={firstOrLastNameValidator}
render={() => {
console.log("Form Render");
return (
<FormElement>
<div className="form-content-container" style={{ overflowY: "scroll" }}>
<UserInformationSection /> //returns Field components wrapped in div
<UserAddressSection /> //returns Field components wrapped in div</div>
</FormElement>
);
}}
/>
);
};
Is there some way to achieve this functionality, so that sets of form Fields can be grouped into components which can be reused in multiple different forms?