Feature request
Submitting a form with no event results in a runtime error.
I'm using React Final Form on React Native and I don't always have an event passed to the submit handler.
<Form
onSubmit={this.onSubmit}
initialValues={/* ... */}
render={({handleSubmit, reset, submitting, pristine, values}) => (
<View style={styles.container}>
<NavigationBar
leftButton="back"
onLeftButtonPress={this.props.navigator.pop}
rightButtonText={t("Save")}
onRightButtonPress={handleSubmit}
/>
...
</Form>
Obviously bad example just to show the error: https://codesandbox.io/s/k10xq99zmr
React Native 0.48
Final Form 3.0.0
React Final Form 2.1.0
It's easy to bypass this error with this:
onRightButtonPress={() => {
handleSubmit({preventDefault: () => {}});
}}
But I would rather have a check in the handleSubmit function to bypass the preventDefault call if no event is passed.
I'm happy to submit a PR to https://github.com/final-form/react-final-form/blob/ec271773fd0f7b0c7f7fe0c4992bfcf021b63dc8/src/ReactFinalForm.js#L109
- event.preventDefault()
+ event && event.preventDefault()
I just need to check with Flow that everything still works
I'm happy to submit a PR

Shouldn't this issue be closed since #84 is merged?
Indeed. Thanks for your vigilance.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment