Skip to content

Brainstorm for all dev consumers: onResolve/onHandleSubmission prop? #5

Description

@Noitidart

This is a food for thought for all devs that use this. If my form is mounted, and it resolves, then I want to navigate to the next screen. So currently I am abusing the getPayload prop for this behavior:

getPayload={handleSubmission}
const handleSubmission = payload => {
    setTimeout(() => {
        // payload is undefined for success, else its SubmissionErrors for final-form
        if (payload === undefined) { 
            navigate('ScreenAfterLogin');
        }
    }, 0);
}

I don't navigate from redux, because after the login flow its not always necessary to navigate('ScreenAfterLogin'). For instance, if during the user using the app, his cookie expires, I show a "relogin screen", and on success there I send him navigation.back().

Aside: I am guessing I have to wrap in setTimeout, so I let the form take the changes, otherwise i get component is not mounted anymore errors.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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