pradel / react-responsive-modal

Simple responsive react modal
https://react-responsive-modal.leopradel.com/
MIT License
606 stars 95 forks source link

Next.js: page won't load if modal is showing at page load #432

Closed giraffesyo closed 3 years ago

giraffesyo commented 3 years ago

Bug report

Thank you very much for the easy to use component. The following isn't an important bug to me, but just letting you know as an FYI because I ran into it while testing.

Describe the bug

Using next.js, if you have the modal open at page load you will get the following error:

Server Error Error: Target container is not a DOM element.

This error happened while generating the page. Any console logs will be displayed in the terminal window.

To Reproduce

Create a next.js project, use the following hook:

  const [modalIsOpen, setModalIsOpen] = React.useState(true)

And use that state within your modal

<Modal open={modalIsOpen} center onClose={() => setModalIsOpen(false)}>Content</Modal>

Expected behavior

Page loads, with modal open.

System information

pradel commented 3 years ago

Thanks for reporting the issue, should be fixed in v5.2.1 :)