Submitting a form with no event results in a runtime error (React Native)
See original GitHub issueAre you submitting a bug report or a feature request?
Feature request
What is the current behavior?
Submitting a form with no event results in a runtime error.
What is the expected behavior?
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>
Sandbox Link
Obviously bad example just to show the error: https://codesandbox.io/s/k10xq99zmr
What’s your environment?
React Native 0.48 Final Form 3.0.0 React Final Form 2.1.0
Other information
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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Running into a state error when attempting to change an input ...
Show activity on this post. I when I pass state down from a parent component the setState keeps throwing an error stating that...
Read more >Error Handling in React 16 – React Blog
As React 16 release is getting closer, we would like to announce a few changes to how React handles JavaScript errors inside components....
Read more >8 common React error messages and how to address them
Learn about the most common error messages in React Development and the meaning behind them, the error itself, and how to fix it....
Read more >Tutorial: Create a Node.js and React app in Visual Studio
Visual Studio usually detects the installed Node.js runtime ... might take a few minutes, and you might not see results immediately.
Read more >Errors | Node.js v19.3.0 Documentation
Indicates that a program is not valid JavaScript. These errors may only be generated and propagated as a result of code evaluation. Code...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.