DEV Community

loading...

Discussion on: Sharing Context with React Portals

Collapse
mickmister profile image
Michael Kochell Author

Libraries that export a Modal component are usually using a Portal under the hood. In this case, you do need that <Modal> inside of the <ImportantValueProvider>. There's no way around it.

Your Provider should be at the top of your application, unless you have multiple instances of the same kind of Provider, which is sort of an anti-pattern unless you have a niche use case that fits it. In short, put your Provider at the top-level of your app and you should be good to go.