naqvitalha naqvitalha - 1 year ago 305
Android Question

React Native (Android): Run inside fragment?

React Native provides an easy way to load JS inside an Activity. I've been trying to do the same inside a fragment. I copied most of the code from ReactActivity class and create a ReactFragment class. I'm still in the middle of figuring this out but I wanted to know if this is even possible. If it's possible what is the easiest way to achieve it?


Answer Source

Turns out this is very much possible. Just return ReactRootView instance on onCreateView. Route all relevant Activity events to the fragment like onBackPressed etc and it'll work predictably.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download