🌐 A component that enables proper layout behavior when React Native views are rendered inside SwiftUI components. It syncs layout information from SwiftUI back to React Native's Yoga layout system by updating the shadow node size.
🌐 When React Native views are placed inside SwiftUI components like BottomSheet, Popover or HStack and so on, the layout systems need to communicate. RNHostView bridges this gap:
🌐 When using flex: 1 in your React Native content, omit the matchContents prop so the content fills the available SwiftUI space.
RNHostView with flex content
import{ useState }from'react';import{Text,View}from'react-native';import{Host,BottomSheet,Button,Group,RNHostView,}from'@expo/ui/swift-ui';import{ presentationDetents }from'@expo/ui/swift-ui/modifiers';functionExample(){const[isPresented, setIsPresented]=useState(false);return(<Hoststyle={{ flex:1}}><Buttonlabel="Open sheet"onPress={()=>setIsPresented(true)}/><BottomSheetisPresented={isPresented}onIsPresentedChange={setIsPresented}><Groupmodifiers={[presentationDetents(['medium','large'])]}><RNHostView><Viewstyle={{
flex:1,
backgroundColor:'#007AFF',
padding:24,}}><Textstyle={{ color:'white', fontSize:18}}>
This content fills the available space
</Text></View></RNHostView></Group></BottomSheet></Host>);}
When true, the RNHost will update its size in the React Native view tree to match the children's size.
When false, the RNHost will use the size of the parent SwiftUI View.
Can be only set once on mount.