AppRegistry
AppRegistry
is the JS entry point to running all React Native apps. App root components should register themselves with AppRegistry.registerComponent
, then the native system can load the bundle for the app and then actually run the app when it's ready by invoking AppRegistry.runApplication
.
import {Text, AppRegistry} from 'react-native';
const App = () => (
<View>
<Text>App1</Text>
</View>
);
AppRegistry.registerComponent('Appname', () => App);
To "stop" an application when a view should be destroyed, call AppRegistry.unmountApplicationComponentAtRootTag
with the tag that was passed into runApplication
. These should always be used as a pair.
AppRegistry
should be required early in the require
sequence to make sure the JS execution environment is setup before other modules are required.
Reference
Methods
getAppKeys()
static getAppKeys(): string[];
Returns an array of strings.
getRegistry()
static getRegistry(): {sections: string[]; runnables: Runnable[]};
Returns a Registry object.
getRunnable()
static getRunnable(appKey: string): : Runnable | undefined;
Returns a Runnable object.
Parameters:
Name | Type |
---|---|
appKey Required | string |
getSectionKeys()
static getSectionKeys(): string[];
Returns an array of strings.
getSections()
static getSections(): Record<string, Runnable>;
Returns a Runnables object.
registerComponent()
static registerComponent(
appKey: string,
getComponentFunc: ComponentProvider,
section?: boolean,
): string;
Parameters:
Name | Type |
---|---|
appKey Required | string |
componentProvider Required | ComponentProvider |
section | boolean |
registerConfig()
static registerConfig(config: AppConfig[]);
Parameters:
Name | Type |
---|---|
config Required | AppConfig[] |
registerRunnable()
static registerRunnable(appKey: string, func: Runnable): string;
Parameters:
Name | Type |
---|---|
appKey Required | string |
run Required | function |
registerSection()
static registerSection(
appKey: string,
component: ComponentProvider,
);
Parameters:
Name | Type |
---|---|
appKey Required | string |
component Required | ComponentProvider |
runApplication()
static runApplication(appKey: string, appParameters: any): void;
Loads the JavaScript bundle and runs the app.
Parameters:
Name | Type |
---|---|
appKey Required | string |
appParameters Required | any |
setComponentProviderInstrumentationHook()
static setComponentProviderInstrumentationHook(
hook: ComponentProviderInstrumentationHook,
);
Parameters:
Name | Type |
---|---|
hook Required | function |
A valid hook
function accepts the following as arguments:
Name | Type |
---|---|
component Required | ComponentProvider |
scopedPerformanceLogger Required | IPerformanceLogger |
The function must also return a React Component.
setWrapperComponentProvider()
static setWrapperComponentProvider(
provider: WrapperComponentProvider,
);
Parameters:
Name | Type |
---|---|
provider Required | ComponentProvider |
unmountApplicationComponentAtRootTag()
static unmountApplicationComponentAtRootTag(rootTag: number);
Stops an application when a view should be destroyed.
Parameters:
Name | Type |
---|---|
rootTag Required | number |
Type Definitions
AppConfig
Application configuration for the registerConfig
method.
Type |
---|
object |
Properties:
Name | Type |
---|---|
appKey Required | string |
component | ComponentProvider |
run | function |
section | boolean |
Note: Every config is expected to set either component
or run
function.
Registry
Type |
---|
object |
Properties:
Name | Type |
---|---|
runnables | array of Runnables |
sections | array of strings |
Runnable
Type |
---|
object |
Properties:
Name | Type |
---|---|
component | ComponentProvider |
run | function |
Runnables
An object with key of appKey
and value of type of Runnable
.
Type |
---|
object |
Last updated: Sep 30, 2025