From 472a636d25913284492070ffd83ca4b435b036c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Mar=C3=A9chal?= Date: Tue, 7 Jul 2026 12:07:58 +0200 Subject: [PATCH 1/2] fix: setState called after unmount in validateForm function. --- src/Formsy.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Formsy.ts b/src/Formsy.ts index 75e8e13d..a10c41e2 100644 --- a/src/Formsy.ts +++ b/src/Formsy.ts @@ -67,6 +67,7 @@ export class Formsy extends React.Component, Form public emptyArray: any[]; public prevInputNames: any[] | null = null; private readonly debouncedValidateForm: () => void; + private mounted: boolean = false; public constructor(props: FormsyProps) { super(props); @@ -85,14 +86,23 @@ export class Formsy extends React.Component, Form }; this.inputs = []; this.emptyArray = []; - this.debouncedValidateForm = debounce(this.validateForm, ONE_RENDER_FRAME); + this.debouncedValidateForm = debounce(() => { + if (this.mounted) { + this.validateForm(); + } + }, ONE_RENDER_FRAME); } public componentDidMount = () => { + this.mounted = true; this.prevInputNames = this.inputs.map((component) => component.props.name); this.validateForm(); }; + public componentWillUnmount = () => { + this.mounted = false; + } + public componentDidUpdate = (prevProps: FormsyProps) => { const { validationErrors, disabled = false } = this.props; From 7bb5a77185b622bad65e44fea1a51a75b0324ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Mar=C3=A9chal?= Date: Tue, 7 Jul 2026 12:08:41 +0200 Subject: [PATCH 2/2] fix: setState called after unmount in validateForm function. --- src/Formsy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Formsy.ts b/src/Formsy.ts index a10c41e2..eb50546b 100644 --- a/src/Formsy.ts +++ b/src/Formsy.ts @@ -101,7 +101,7 @@ export class Formsy extends React.Component, Form public componentWillUnmount = () => { this.mounted = false; - } + }; public componentDidUpdate = (prevProps: FormsyProps) => { const { validationErrors, disabled = false } = this.props;