erikras/react-redux-promise-listener

Brainstorm for all dev consumers: onResolve/onHandleSubmission prop?

Noitidart opened this issue · 0 comments

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.