Skip to content

Commit 9a46b86

Browse files
author
erikras-dinesh-agent
committed
Test: regression test for nested Field with validator infinite loop (#914)
1 parent e82df67 commit 9a46b86

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/ReactFinalForm.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,3 +991,33 @@ describe("ReactFinalForm", () => {
991991
expect(getByTestId("password").value).toBe("f1nal-f0rm-RULEZ");
992992
});
993993
});
994+
995+
describe("Issue #914 – nested Field with validator causing Maximum update depth", () => {
996+
it("should not throw Maximum update depth exceeded when nesting Fields with validators", () => {
997+
// https://github.com/final-form/react-final-form/issues/914
998+
const required = (value) => (value ? undefined : "Required");
999+
1000+
expect(() => {
1001+
render(
1002+
<Form onSubmit={onSubmitMock}>
1003+
{({ handleSubmit }) => (
1004+
<form onSubmit={handleSubmit}>
1005+
<Field name="outer" validate={required}>
1006+
{({ input }) => (
1007+
<div>
1008+
<input {...input} data-testid="outer" />
1009+
<Field name="inner" validate={required}>
1010+
{({ input: innerInput }) => (
1011+
<input {...innerInput} data-testid="inner" />
1012+
)}
1013+
</Field>
1014+
</div>
1015+
)}
1016+
</Field>
1017+
</form>
1018+
)}
1019+
</Form>,
1020+
);
1021+
}).not.toThrow();
1022+
});
1023+
});

0 commit comments

Comments
 (0)