External Component
The ExternalComponent layout allows you to display any native view as a screen. To use the External Component we'll need to register it with a string name. This name is then used when declaring layouts in JS.
#
Android#
Implementing the native componentWhen it comes to implementing an external component on Android, you have two choices. We recommend you use a base class extending View
. If you're required to use Fragments, you'll find an basic example below.
#
ViewGroup#
FragmentUsing a Fragment as an external component is done by attaching the Fragment to a FrameLayout, and returning the FrameLayout from the asView()
method of the ExternalComponent.
#
Registering the component#
iOS#
ViewController registration#
Using the component from JSOnce you've registered the external component in native, you can use it in your layout declarations. For example, to show an external component modally:
caution
props passed to external components are sent over the bridge and therefore must be serializable.