Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update notification on redux dispatch not working #45

Closed
stefensuhat opened this issue Jun 18, 2017 · 2 comments
Closed

Update notification on redux dispatch not working #45

stefensuhat opened this issue Jun 18, 2017 · 2 comments

Comments

@stefensuhat
Copy link

stefensuhat commented Jun 18, 2017

Configuration

  • Operating system with version : Windows 10
  • Browser with version : Chrome 59
  • Reapop version : latest
  • React version : latest
  • Redux version : latest
  • React-redux version : latest
export function handleDelete(formData) {
    return (dispatch) => {
        dispatch({
            type: DELETE_MENU
            payload: new Promise((resolve, reject) => {
                let notif = notify({
                    status: 'loading',
                    title: 'Deleting.....',
                })
               dispatch(notif);
                client.post('menus/delete', formData)
                    .then(({ meta }) => {
                        notif.status = 'success';
                        notif.message = 'Your file has been successfully deleted';
                        notif.dismissible = true;
                        notif.dismissAfter = 5000;
                        updateNotification(notif);
                        resolve(formData);
                    })
                    .catch((error) => {
                        errorHandler(error);
                        reject(error);
                    });
            }),
        });
    };
}

The problem is the notif with loading is spawn correctly. But when the promise is done, and updateNotification is not properly running (the loading notif still shown).

@joerodrig
Copy link

@stefensuhat Try calling dispatch(updateNotification(notif))

@LouisBarranqueiro
Copy link
Owner

Oh sorry @stefensuhat, I didn't see your issue.
as @joerodrig said, you need to dispatch this action yes :)

Thanks @joerodrig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants