naqvitalha naqvitalha - 5 months ago 146
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?



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.