Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Promise on Submit #2

@Ellisande

Description

@Ellisande

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions