ReactNative源码分析之UIManagerModule

本文深入分析ReactNative 0.61.5版本的UIManagerModule,它是NativeModule的一种,负责管理ViewManager。内容涵盖mViewManagerRegistry的职责、EventDispatcher在UI变化时的消息传递到JS层的角色,以及ReactMethod注解的方法,包括createView、updateView等关键操作。文章还提及UIImplementation作为代理的角色,将在后续分析中进一步探讨。
摘要由CSDN通过智能技术生成

当前分析的ReactNative版本为0.61.5:

今天的主角是UIManagerModule,我们看它的定义,本质上是个NativeModule,可以通过ReactContext访问。

先来看看它的私有变量mViewManagerRegistry,该类负责管理ViewManagerName和ViewManager关系,可以通过ViewManagerName查找对应的ViewManager。

代码实现如下:

/**
 * Class that stores the mapping between native view name used in JS and the corresponding instance
 * of {@link ViewManager}.
 */
public final class ViewManagerRegistry {
   

  private final Map<String, ViewManager> mViewManagers;
  private final @Nullable UIManagerModule.ViewManagerResolver mViewManagerResolver;

  public ViewManagerRegistry(UIManagerModule.ViewManagerResolver viewManagerResolver) {
   
    mViewManagers = MapBuilder.newHashMap();
    mViewManagerResolver = viewManagerResolver;
  }

  public 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值