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.

Provide a set of callbacks to onSubmit method

See original GitHub issue

Provide a set of callbacks to onSubmit method, for example reset function

Are you submitting a bug report or a feature request?

feature request

What is the current behavior?

<Form
  onSubmit={onSubmit}
  initialValues={{ employed: true }}
  render={({ handleSubmit, reset }) => (
    <form
      onSubmit={event => {
        handleSubmit(event).then(() => {
          reset() // or could be passed directly to then()
        })
      }}
    >
    ...
    </form>
  }/>

What is the expected behavior?

const onSubmit = (values, reset) =>  {
    return new Promise (resolve => {
        reset();
        resolve();
    }
};
<Form
  onSubmit={onSubmit}
  initialValues={{ employed: true }}
  render={({ handleSubmit, reset }) => (
    <form  onSubmit={handleSubmit}>
    ...
    </form>
  }/>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
good-ideacommented, Jan 19, 2018

Oh of course, yes, I mean that I’d put one together. Hopefully early next week!

2reactions
scsirdxcommented, Feb 1, 2018

Another way to do it is to wrap actual action in promise and send resolve/reject with it.

submit(values) {
  return new Promise((resolve, reject) => {
    updateAction({ values, resolve, reject });
  });
}

Then in saga you can call yield call(resolve, ...) or reject. So promises will be there and it will be possible to use .then(reset).

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactJS: Form onSubmit failing to call callback - Stack Overflow
Passing this.onSubmit to the form's onSubmit callback prop causes the onSubmit() method that you've defined to be called, which in turn causes ...
Read more >
How onsubmit Event work in JavaScript? Examples - eduCBA
The onsubmit event is performed the triggers is based upon the submit function whenever the client user request in the form-wise data is...
Read more >
Callback functions - Vanilla Embed Library - Typeform's APIs
The onSubmit callback will execute immediately after a respondent successfully submits the typeform by clicking the "Submit" button.
Read more >
How to perform jQuery Callback after submitting the form
First, the elements in a form must be ensured if it is loaded. · Then, the submit method is added a callback function....
Read more >
HTMLFormElement: submit event - Web APIs | MDN
Use the event name in methods like addEventListener() , or set an event handler property. addEventListener('submit', (event) => {}) ...
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