I used a material -ui Dialog. The dialog is not able to open and close repeatly for my lack of ability. After closing the dialog , it was no logener open again. How Should I fix my code? I am using React and Redux . function OpenPepsi is in Container. can is got from Promise object.
function MainPage(props: Material) {
return (
<React.Fragment>
<Link variant="h3" onClick={props.OpenPepsi}>
OpenPepsiDialog
</Link>
<br />
{props.can && (
<PepsiDialog
can ={props.can}
isOpen={!!props.can}
/>
)}
function PepsiDialog(props: {
c: can;
isOpen: boolean;
}) {
const [open, setOpen] = React.useState(props.isOpen);
const handleClose = () => {
setOpen(false);
};
return (
<Dialog open={open} onClose={handleClose}>
<React.Fragment>{c}</React.Fragment>
);
action
export const OPEN_PEPSI = () => async (dispatch: Dispatch) => {
const can = await getPepsi(FOO);
dispatch(OPEN_PEPSI_NOTIFY(can));
};
opentotrue, but only tofalseor at least in your code listing it's not visible.