question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow appElement prop to call setAppElement

See original GitHub issue

Summary:

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:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
YPCrumblecommented, Sep 8, 2021

Thanks again! The code works as you wrote it above 😄.

1reaction
YPCrumblecommented, Sep 8, 2021

@diasbruno so sorry - your code works I had just implemented it wrong! Thanks again for this library and your patience with my issue - closing.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found