-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React Portal children gets overriden in Fabric #36273
Comments
|
|
More findings - createContainerChildSet gets called twice. As it returns a new childSet, second call overrides the children added previously. I think we might have to append if it's already created. |
Portals are not supported in React Native. You can achieve similar behaviour with custom native components by manually "portalling" children to a different container. |
@javache they aren't supported, but is there any plan to support them? They are a pretty big missing gap between web and native, would be nice to have a place to track their plan. Manually moving things around will break context entirely, which makes them very awkward in practice. |
Description
Portals are not officially documented in RN. But I think it can be a very useful feature and it almost works!
Why do we need Portals?
Modal component cannot be used as a general-purpose overlay solution as multiple modals on iOS are tricky and Modal also prevents behind view touches. Userland solution loses React context when children are mounted.
Issue
I got createPortal working on Paper architecture by removing this assertion. However I ran into an issue on Fabric. After some digging, I found that the issue is in the React Fabric JS renderer, not native side. The Portal gets mounted momentarily but gets overridden by the HostRoot children.
Here is the repro. In the repro, two calls are made to
updateHostContainer
. 1 and 2. The second call from HostRoot overrides the children mounted by Portal. These findings are with some console.logs, I have no clue how it works. I'll try to dig more and update. I think @rickhanlonii can help 🙏React Native Version
0.71.3
Output of
npx react-native info
Steps to reproduce
Snack, code example, screenshot, or link to a repository
RNTester Repro
The text was updated successfully, but these errors were encountered: