Test A Component That Uses React Portals
Last updated
Was this helpful?
Last updated
Was this helpful?
When using to render a component that uses , you'll probably run into an issue with your Portal
code. When trying to set up the portal, it will fail to find the portal's root element in the DOM.
There are . , recommended by KCD, is to add the portal's root element to the document if it's not already there.
By solving this issue directly in the portal's source code, you are making it more reliable and don't have to add extra boilerplate to your test setup.