In fact, you are almost in the right direction. The reason your FrameLayout is not showing is because you have not explicitly added a style to ReactNative to determine its height and width. However, even in this case, your fragment will also not be displayed. There are several changes you can make to visualize your fragment.
In your ViewManager, make the following changes:
@Override public FrameLayout createViewInstance(ThemedReactContext context) { final FrameLayout view = new FrameLayout(context); MyFragment fragment = MyFragment.newInstance();
Then in your ReactNative component
class ExampleComponent extends React.Component { render() { return ( <View> <Text>Hello</Text> <RCTPreferenceView {...this.props} style={{ height: "80%", width: "100%" }} /> </View> ); } }
Hope this helps someone trying to render a fragment in a ReactNative view
source share