naqvitalha
naqvitalha

Reputation: 793

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?

Thanks!

Upvotes: 2

Views: 690

Answers (1)

naqvitalha
naqvitalha

Reputation: 793

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.

Upvotes: 1

Related Questions