Skip to content

Commit

Permalink
Prevent setState calls in submit if unmounted after validation (#861)
Browse files Browse the repository at this point in the history
* Prevent setState calls in submit if unmounted after validation

* Allow submission even if unmounted
jaredpalmer authored Aug 30, 2018
1 parent 11a1362 commit 01f852e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Formik.tsx
Original file line number Diff line number Diff line change
@@ -427,7 +427,8 @@ export class Formik<Values = {}, ExtraProps = {}> extends React.Component<
const isValid = Object.keys(combinedErrors).length === 0;
if (isValid) {
this.executeSubmit();
} else {
} else if (this.didMount) {
// ^^^ Make sure Formik is still mounted before calling setState
this.setState({ isSubmitting: false });
}
});

0 comments on commit 01f852e

Please sign in to comment.