Welcome to react-modal-global Discussions! #11
Replies: 7 comments 20 replies
-
how could i rerender in Popup, coz i need to open muiti popup and i just use function firstpopup() {
const [test, setTest] = React.useState('aa');
const openPopuptest = useCallback(
() =>
Modal.open(secondpopup, {
test: test,
setTest: setTest,
layer: 44,
}),
[test]
);
return (
<>
<h2>{test}</h2>
<button onClick={openPopuptest}>Popuptest</button>
</div>
</>
);
}
function secondpopup(props) {
const {test, setTest}= props
const click = useCallback(
() =>
setTest('ee')
[setTest]
);
return (
<>
<h2>{test}</h2>. // after click still "aa". expect "ee"
<button onClick={click}>Popuptest</button>
</div>
</>
);
} |
Beta Was this translation helpful? Give feedback.
-
@wspkiki1992 If you need tightly connected Personally, I advice using recoil since it creates local context only between components it's used. Currently, there is no way to pass dynamic state to a Modal that is opened using |
Beta Was this translation helpful? Give feedback.
-
if use lazy load in component Modal.closeByComponent() didn't work const PopDialog = new ModalController({
components: {
NormalLoginContent: lazy(() => import("views/login/sub/normalLoginContent/NormalLoginContent")),
ErrorNotice: lazy(() => import("components/popDialog/sub/errorNotice")),
Store: lazy(() => import("components/header/sub/store")),
},
defaultParams: {
closable: false,
},
});
<div className={styles.topBar}>
{t("Account Login")}
<Button
onClick={() => {
Modal.closeByComponent(NormalLoginContent)
}}
className={styles.close}
>
<CloseIcon sx={{ fontSize: "3vw" }} />
</Button>
</div> |
Beta Was this translation helpful? Give feedback.
-
put const modal = useModalWindow() in login page show error ModalError: useModalWindow must be used within a modal context. |
Beta Was this translation helpful? Give feedback.
-
how to open a new modal when everytime open, coz i need to call api in useEffect everytime when i open, but Data preservation will restore it |
Beta Was this translation helpful? Give feedback.
-
TypeError: [...this.windows].at is not a function. (In '[...this.windows].at(-1)', '[...this.windows].at' is undefined) only have error on desktop safari , have try chrome and mobile safari all good |
Beta Was this translation helpful? Give feedback.
-
https://1cj3vy.csb.app/ |
Beta Was this translation helpful? Give feedback.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions