Open sandlz opened 4 months ago
@supnate can you help me? thanks.
Hi @sandlz,
I made the same issue a while ago (https://github.com/eBay/nice-modal-react/issues/116), it was resolved but it did not fix the unnecessary re-renders.
My solution, albeit not ideal, was to implement another library (https://github.com/raotaohub/ez-modal-react) to be used as the nested modal.
This prevented re-render on the first modal, which is great. But it's not ideal having 2 libraries that do the same thing..
Business description
In my App, there are a lot of modals that need to be displayed, so in some business scenarios, there may be 5 or more modals displayed cascading.
As follows: Modal-A -- Modal-B ------ Modal-C ---------- Modal-D
Code description
Example link
in
App.tsx
muti
modal.tsx
ModalA.tsx
, click will showModalB
ModalB.tsx
, click will showModalC
...const ModalA = NiceModal.create(() => { const modal = useModal();
console.log("Modal [A] render",
id: ${modal.id}, visible: ${modal.visible}
); const showModalB = () => { NiceModal.show(ModalConstant.modalB, {}); };return ( <BootstrapModal {...bootstrapDialog(modal)}>
This is modal A.