react-native-macos/docs/appregistry.md

4.4 KiB

id title layout category permalink next previous
appregistry AppRegistry docs APIs docs/appregistry.html appstate animated

Project with Native Code Required

This API only works in projects made with react-native init or in those made with Create React Native App which have since ejected. For more information about ejecting, please see the guide on the Create React Native App repository.

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.

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.

Methods


Reference

Methods

setWrapperComponentProvider()

static setWrapperComponentProvider(provider)

registerConfig()

static registerConfig(config)

registerComponent()

static registerComponent(appKey, componentProvider, section?)

registerRunnable()

static registerRunnable(appKey, run)

registerSection()

static registerSection(appKey, component)

getAppKeys()

static getAppKeys()

getSectionKeys()

static getSectionKeys()

getSections()

static getSections()

getRunnable()

static getRunnable(appKey)

getRegistry()

static getRegistry()

setComponentProviderInstrumentationHook()

static setComponentProviderInstrumentationHook(hook)

runApplication()

static runApplication(appKey, appParameters)

unmountApplicationComponentAtRootTag()

static unmountApplicationComponentAtRootTag(rootTag)

registerHeadlessTask()

static registerHeadlessTask(taskKey, task)

Register a headless task. A headless task is a bit of code that runs without a UI.

Parameters:

Name Type Required Description
taskKey string No The key associated with this task.
task function No A promise returning function that takes some data passed from the native side as the only argument; when the promise is resolved or rejected the native side is notified of this event and it may decide to destroy the JS context.

startHeadlessTask()

static startHeadlessTask(taskId, taskKey, data)

Only called from native code. Starts a headless task.

Parameters:

Name Type Required Description
taskId number No The native id for this task instance to keep track of its execution
taskKey string No The key for the task to start
data any No The data to pass to the task