question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Submitting a form with no event results in a runtime error (React Native)

See original GitHub issue

Are 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:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
erikrascommented, Dec 27, 2017

I’m happy to submit a PR

web image 2017-12-27 15-09-22

0reactions
lock[bot]commented, Jan 16, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found