Allow appElement prop to call setAppElement
See original GitHub issueSummary:
Currently I don’t think react-modal is compatible with code splitting using loadable-components because of needing to call Modal.setAppElement()
. The issue is that if we load the Modal
element like this:
const Modal = loadable(() => import('react-modal'))
…then Modal
won’t have resolved at runtime when we call Modal.setAppElement
.
My suggestion is to call setAppElement
from within the constructor if we pass an appElement
prop to the Modal
.
Thanks for maintaining this repo, and please let me know if a PR to do the above would be welcomed, as I’d love to contribute!
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
"Warning: react-modal: App element is not defined. Please ...
setAppElement () is called with null or not called at all with the ... Props { isOpen: boolean ariaLabel?: string } const Modal:...
Read more >Accessibility - react-modal documentation
To allow react-modal to do this, you should call Modal.setAppElement with a query selector identifying the root of your app. For example, if...
Read more >Warning: react-modal: App element is not defined. #576 - GitHub
Once I wrapped the setAppElement call in a check to make sure it was in a client/browser environment then it appears to run...
Read more >Warning: react-modal: App element is not defined. Please use ...
Coding example for the question "Warning: react-modal: App element is not defined. Please use `Modal.setAppElement(el)` or set `appElement={el}`"-Reactjs.
Read more >react-modal - npm
The Modal object has two required props: ... setAppElement(appElement); * query selector - uses the first element found if you pass in a ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks again! The code works as you wrote it above 😄.
@diasbruno so sorry - your code works I had just implemented it wrong! Thanks again for this library and your patience with my issue - closing.