Problem on Dispatching Actions in React Using Redux

Viewed 55

I have a dialog that is reusable. I have just ONE dialog for confirmation in logging out and for deleting. My problem is on the logging out, once i confirm the logout, the action that is firing is the deletion. I have put a console.log console.log("SUCCESS LOGOUT") console.log("DELETE USER SUCCESS"); to see if what action successfully fires and its the delete action. How will i fix this? Thank you.

SEE THIS LINK

CLICK HERE

Dialog

    const ReusableDialog = ({
      title,
      details,
      open,
      type,
      onAgree,
      onDisagree
    }) => {
      return (
        <div>
          <Dialog
            open={open}
            TransitionComponent={Transition}
            keepMounted
            onClose={onDisagree}
            aria-labelledby="alert-dialog-slide-title"
            aria-describedby="alert-dialog-slide-description"
          >
            <DialogTitle id="alert-dialog-slide-title">
              <span>
                Are you sure you want to {title} {details?.name}
              </span>
            </DialogTitle>
            <DialogActions>
              <Button variant="contained" size="small" onClick={onDisagree}>
                Cancel
              </Button>
              <Button variant="contained" size="small" onClick={onAgree}>
                Confirm
              </Button>
            </DialogActions>
          </Dialog>
        </div>
      );
    };

export default ReusableDialog;
1 Answers

Two dialog's are opening at once. As you are using the global single state for dialog, two dialogss are being opened one from the users.js and one from navbar.js.

They are overlapping hence you can't see them add a big title to one of them and then see.

Why would you want a Global state for dialog? A local state should solve your problem.

Related