informative
informative copied to clipboard
Promise on Submit
Maybe this is more of a hassle than its worth, but what if instead of requiring a promise on submit we provided a closure to them that makes them handle success or failure?
if (this.props.onSubmit) {
const successful = succeed => succeed ? this.submitSucceed() : this.submitFailed();
this.props.onSubmit(values, this.state, successful)
}
The downside is it makes it less straight forward if you already using promises all over, but leaves flexibility there if you are using callbacks, or doing something like just dispatching an action as part of your onSubmit
function. If we do go that route I think it would make sense to optimistically mark submitted: true
if its submitted and passed validation, but before we invoke their callback.