Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/ReactFinalForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ReactFinalForm extends React.Component<Props, State> {
state: State
form: FormApi
mounted: boolean
submitLock: boolean
resumeValidation: ?boolean
unsubscriptions: Unsubscribe[]

Expand All @@ -59,6 +60,7 @@ class ReactFinalForm extends React.Component<Props, State> {
} = props
const config: Config = rest
this.mounted = false
this.submitLock = false
try {
this.form = createForm(config)
} catch (e) {
Expand Down Expand Up @@ -101,7 +103,23 @@ class ReactFinalForm extends React.Component<Props, State> {
event.stopPropagation()
}
}
return this.form.submit()

if (this.submitLock) {
return
}

const onComplete = () => (this.submitLock = false)

this.submitLock = true
const result = this.form.submit()

if (result && typeof result.then === 'function') {
result.then(onComplete, onComplete)
} else {
onComplete()
}

return result
}

componentWillMount() {
Expand Down