Skip to content

Instantly share code, notes, and snippets.

@gabrielhpugliese
Created March 7, 2016 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielhpugliese/2c7418a682a3f42ecb8d to your computer and use it in GitHub Desktop.
Save gabrielhpugliese/2c7418a682a3f42ecb8d to your computer and use it in GitHub Desktop.
<form
onSubmit={handleSubmit(values => (
new Promise((resolve, reject) => {
// errorsForm returns an Object where keys are fields with errors and values are messages to show in form.
const errors = this.errorsForm(values);
if (! isEmpty(errors)) {
return reject(errors);
}
return postToMyServer(values)
.then(() => {
return resolve();
});
}))}
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment