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
As the title says, when I create a reusable component , and pass the props closeModal and isOpen, it doesnt animate the onClose, as if I add the modal directly on my component.
Where im using it
<ModalisOpen={isOpen}closeModal={closeModal}title="Hi"description="Your payment has been successfully submitted. We’ve sent you an email with all of the details of your order.">
Test
</Modal>
Modal component
constModal=({ isOpen, closeModal, children, title, description })=>{if(!isOpen)returnnullreturn(<Transitionappearshow={isOpen}as={Fragment}><Dialogas="div"className="relative z-10"onClose={closeModal}><Transition.Childas={Fragment}enter="ease-out duration-300"enterFrom="opacity-0"enterTo="opacity-100"leave="ease-in duration-200"leaveFrom="opacity-100"leaveTo="opacity-0"><divclassName="fixed inset-0 bg-black/25"/></Transition.Child><divclassName="fixed inset-0 overflow-y-auto"><divclassName="flex items-center justify-center min-h-full p-4 text-center"><Transition.Childas={Fragment}enter="ease-out duration-300"enterFrom="opacity-0 scale-95"enterTo="opacity-100 scale-100"leave="ease-in duration-200"leaveFrom="opacity-100 scale-100"leaveTo="opacity-0 scale-95"><Dialog.PanelclassName="w-full max-w-md p-6 overflow-hidden text-left align-middle transition-all transform bg-white shadow-xl rounded-2xl"><Dialog.Titleas="h3"className="text-lg font-medium leading-6 text-gray-900">
Payment successful
</Dialog.Title><divclassName="mt-2"><pclassName="text-sm text-gray-500">
Your payment has been successfully submitted. We’ve sent you an email with all of the details of your order.
</p></div><divclassName="mt-4"><buttontype="button"className="inline-flex justify-center px-4 py-2 text-sm font-medium text-blue-900 bg-blue-100 border border-transparent rounded-md hover:bg-blue-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2"onClick={closeModal}>
Got it, thanks!
</button></div></Dialog.Panel></Transition.Child></div></div></Dialog></Transition>)}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
As the title says, when I create a reusable component , and pass the props closeModal and isOpen, it doesnt animate the onClose, as if I add the modal directly on my component.
Where im using it
Modal component
Beta Was this translation helpful? Give feedback.
All reactions