-
Notifications
You must be signed in to change notification settings - Fork 141
Description
Introduction
React Native portals would allow to render a component into a different native hierarchy while preserving the context and react tree hierarchy. This feature already exists in the source code and works fine on Android but throws this error on iOS.
I have created a repo that makes this feature work on iOS and Android in the current non-fabric architecture.
Details
I tried a fix on iOS by commenting this assertion. This assertion states that the container should be a root shadow view instance. The above error doesn't occur if we pass rootTag (e.g. one which we get in logs on app start) in createPortal API. However, to make the Portal work consistently on iOS and Android we might need to remove this assertion or find an alternate way (I am not sure why this assertion is added).
Discussion points
- Is there an alternate way to keep the assertion and make Portals work on iOS?
- The Portal API would be a great addition for usecases like Toasts, Alerts, BottomSheets etc and can be used as an alternate to multiple modal usecases.
- I am yet to test this on fabric architecture. Fabric uses UIManager.cpp and this assertion exists on RCTUIManager. I'll try to test it.
Since this feature is not yet exported officially, I thought of starting it as a discussion. :)