Skip to content

Commit 0e9c411

Browse files
erikras-gilfoyle-agenterikras-dinesh-agent
andauthored
Test: regression test for nested Field with validator infinite loop (#914) (#1080)
Co-authored-by: erikras-dinesh-agent <dinesh@openclaw.dev>
1 parent f3803b0 commit 0e9c411

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

src/ReactFinalForm.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,3 +1048,33 @@ describe("ReactFinalForm", () => {
10481048
expect(calls[calls.length - 1]).toBe(false);
10491049
});
10501050
});
1051+
1052+
describe("Issue #914 – nested Field with validator causing Maximum update depth", () => {
1053+
it("should not throw Maximum update depth exceeded when nesting Fields with validators", () => {
1054+
// https://github.com/final-form/react-final-form/issues/914
1055+
const required = (value) => (value ? undefined : "Required");
1056+
1057+
expect(() => {
1058+
render(
1059+
<Form onSubmit={onSubmitMock}>
1060+
{({ handleSubmit }) => (
1061+
<form onSubmit={handleSubmit}>
1062+
<Field name="outer" validate={required}>
1063+
{({ input }) => (
1064+
<div>
1065+
<input {...input} data-testid="outer" />
1066+
<Field name="inner" validate={required}>
1067+
{({ input: innerInput }) => (
1068+
<input {...innerInput} data-testid="inner" />
1069+
)}
1070+
</Field>
1071+
</div>
1072+
)}
1073+
</Field>
1074+
</form>
1075+
)}
1076+
</Form>,
1077+
);
1078+
}).not.toThrow();
1079+
});
1080+
});

0 commit comments

Comments
 (0)