You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I upgraded mui-modal-provider from 1.3.2 to latest version
If you run the following code, you can see it works well on version 1.3.2 but we have error on latest version
If you clock on Simple dialog twice you can see
Cannot read property 'props' of undefined
import React from "react";
import ModalProvider, { useModal } from "mui-modal-provider";
import Dialog from "@material-ui/core/Dialog";
import DialogTitle from "@material-ui/core/DialogTitle";
import Button from "@material-ui/core/Button";
// ✔️ create the dialog you want to useconstSimpleDialog= ({ title, ...props }) => (
<Dialog {...props}><DialogTitle>{title}</DialogTitle></Dialog>
);
constTest= ({ onClick, title ="Simple dialog" }) => {
const { showModal, hideModal } =useModal();
return (
<Button
variant="contained"
onClick={() => {
if (onClick) {
onClick(hideModal);
}
showModal(SimpleDialog, { title });
}}
color="primary">
simple dialog
</Button>
);
};
constApp= () => {
const title =<Test onClick={(hideModal) =>hideModal()} />;
return (
<ModalProvider><Test title={title} /></ModalProvider>
);
};
export default App;
The text was updated successfully, but these errors were encountered:
Thanks for this comment! I just published a new version of the package. Now this code works as expected (error is handled), but don't forget to provide the modal ID argument to the hideModal(id) function - this is mandatory.
The ID is optional if you call the hide function on a modal instance.
I upgraded mui-modal-provider from
1.3.2
to latest versionIf you run the following code, you can see it works well on version
1.3.2
but we have error on latest versionIf you clock on
Simple dialog
twice you can seeThe text was updated successfully, but these errors were encountered: