首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

AppRegistry

需要本机代码的项目

此API仅适用于react-native init使用Create React Native App创建的项目或使用Create React Native App创建的项目,该项目已经弹出。有关弹出的更多信息,请参阅创建React Native App存储库的指南

AppRegistry是运行所有React Native应用程序的JS入口点。应用程序根组件应该自行注册AppRegistry.registerComponent,然后本机系统可以加载该应用程序包,然后在调用准备就绪时真正运行该应用程序AppRegistry.runApplication

要在视图被销毁时“停止”应用程序,请调用AppRegistry.unmountApplicationComponentAtRootTag传入的标记runApplication。这些应该始终用作一对。

AppRegistry应该requirerequire序列的早期阶段确保JS执行环境在其他模块是required 之前设置。

方法

static setWrapperComponentProvider(provider)

static registerConfig(config)

static registerComponent(appKey, componentProvider, section?)

static registerRunnable(appKey, run)

static registerSection(appKey, component)

static getAppKeys()

static getSectionKeys()

static getSections()

static getRunnable(appKey)

static getRegistry()

static setComponentProviderInstrumentationHook(hook)

static runApplication(appKey, appParameters)

static unmountApplicationComponentAtRootTag(rootTag)

static registerHeadlessTask(taskKey, task)

注册一个无头的任务。无头的任务是一些没有UI的代码。@param taskKey与此任务关联的密钥@param任务承诺返回函数,该函数将从本机端传递的一些数据作为唯一参数; 当承诺被解决或拒绝时,本地方会收到有关此事件的通知,并可能决定销毁JS上下文。

static startHeadlessTask(taskId, taskKey, data)

只从本机代码中调用。开始一项无头的任务。

@param taskId此任务实例的本机ID以跟踪其执行情况@param taskKey任务启动的关键@参数数据要传递给任务的数据

扫码关注腾讯云开发者

领取腾讯云代金券