Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make DevTools and React Modal play together nicely #98

Open
andrejak opened this issue Sep 23, 2019 · 2 comments
Open

Make DevTools and React Modal play together nicely #98

andrejak opened this issue Sep 23, 2019 · 2 comments
Labels
devtools ⚒ Related to the devtools plugin

Comments

@andrejak
Copy link
Contributor

andrejak commented Sep 23, 2019

React-modal can throw errors when wrapped in devtools, e.g. in the kanban example.

A quick fix was introduced here, but it probably won't work for all modals: 10f1629

@andrejak
Copy link
Contributor Author

To be honest, I still don't fully understand this bug. But there are multiple workarounds. The nicest one for the user is probably that we recommend using the appElement attribute for the modal instead of the Modal.setAppElement(...) function, i.e. do this:
<Modal appElement={document.getElementById("modal")} {...props}>
Not this:
Modal.setAppElement("#modal")

In the kanban example, the above code is in a useEffect hook in the Modal component. You'd expect that to run after the component has mounted and there should be a div with the modal id on the page (which is defined somewhere). But for some reason it doesn't seem to see it, and throws an error about it missing. I've tried a couple different ways of rendering the user app but haven't found a better one yet.

Currently the patch for kanban was to add a div with the modal id in the devtools core repo - so another workaround would be to tell users to just stick to that id... But that seems quite janky.

@andrejak andrejak added the devtools ⚒ Related to the devtools plugin label Oct 2, 2019
@andrejak
Copy link
Contributor Author

andrejak commented Oct 4, 2019

Encountering a somewhat similar issue with react-select.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devtools ⚒ Related to the devtools plugin
Projects
None yet
Development

No branches or pull requests

1 participant