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.
Update:
React Component (JS file):
export default class MyCustomView extends Component {
render() {
return (

{
MyLayout.openBlankFragment(12345)

}

);
}
}
const MyLayout = NativeModules.MyModule;

MyModule (Java Code):
@ReactMethod
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() {
@Override
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);
transaction.commit();

}
});
}

view.getId() is not recognized. Need help here. If i set the activity root view id like “transaction.add(android.R.id.content, 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

Solutions/Answers:

References