ReactNativeHost
Kind: class
This is the main entry-point to create a React instance.
The ReactNativeHost
object exists to configure the instance using ReactInstanceSettings
before it is loaded, as well as enabling control of when to load the instance.
Use ReactInstanceSettings
events to observe instance creation, loading, and destruction.
Properties
InstanceSettings
ReactInstanceSettings
InstanceSettings
Provides access to this host's ReactInstanceSettings
to configure the react instance.
PackageProviders
readonly
IVector
<IReactPackageProvider
> PackageProviders
Provides access to the list of IReactPackageProvider
's that the React instance will use to provide native modules to the application. This can be used to register additional package providers, such as package providers from community modules or other shared libraries.
Constructors
ReactNativeHost
ReactNativeHost
()
Methods
FromContext
static
ReactNativeHost
FromContext
(IReactContext
reactContext)
Returns the ReactNativeHost
instance associated with the given IReactContext
.
LoadInstance
IAsyncAction
LoadInstance
()
Loads a new React instance. It is an alias for ReloadInstance
method.
ReloadInstance
IAsyncAction
ReloadInstance
()
Unloads the current React instance and loads a new one.
The React instance loading creates an instance of the JavaScript engine, and launches the provided JavaScript code bundle.
If a React instance is already running in this host, then ReloadInstance
shuts down the already the running React instance, and loads a new React instance.
The React instance lifecycle can be observed with the following events:- The ReactInstanceSettings.InstanceCreated
event is raised when the React instance is just created.
- The
ReactInstanceSettings.InstanceLoaded
event is raised when the React instance completed loading the JavaScript bundle. - The
ReactInstanceSettings.InstanceDestroyed
event is raised when the React instance is destroyed.
UnloadInstance
IAsyncAction
UnloadInstance
()
Unloads current React instance.
After the React instance is unloaded, all the React resources including the JavaScript engine environment are cleaned up.
The React instance destruction can be observed with the ReactInstanceSettings.InstanceDestroyed
event.