React Native : add fragment to mainactivity using Android Native Modules

React Native : add fragment to mainactivity using Android Native Modules

I have a specific Android native library to integrate the camera features. The library provides the Fragment with the all it features. I just want to integrate that with Mainactivity in React Native app.
I have followed the link “Add fragment into react-native view”
Also i have gone through many tutorials. But I am stuck up at the place where we add the fragment into the Mainactivity container layout of React native app.
React Component (JS file):
export default class MyCustomView extends Component {
render() {
return (



const MyLayout = NativeModules.MyModule;

MyModule (Java Code):
private void openBlankFragment(final int viewId) {
// Log.v(“View Tag”, “View ID: “+viewId); it prints tag 12345
UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class);

uiManager.addUIBlock(new UIBlock() {
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
View view = nativeViewHierarchyManager.resolveView(viewId);

final Activity activity = getCurrentActivity();
BlankFragment fragment = new BlankFragment();
FragmentTransaction transaction = ((MainActivity)activity).getSupportFragmentManager().beginTransaction();
transaction.add(view.getId(), fragment);


view.getId() is not recognized. Need help here. If i set the activity root view id like “transaction.add(, fragment);”. Its working fine and i can my fragment. But i need to setup my fragment as view in React screen like a frame.

Related:  ReactJS apply multiple inline styles