跳到主要内容

React instance map

ReactInstanceMap 维护从面向公共的有状态实例(键)到内部表示(值)的映射。 这允许公共方法接受面向用户的实例作为参数,并将其映射回内部方法。

注意

注意,该模块目前是共享的,并假定为无状态。 如果它变成真正的 Map,将会失效。

/**
* `ReactInstanceMap` maintains a mapping from a public facing stateful
* instance (key) and the internal representation (value). This allows public
* methods to accept the user facing instance as an argument and map them back
* to internal methods.
*
* Note that this module is currently shared and assumed to be stateless.
* If this becomes an actual Map, that will break.
*/

export function get(key) {
return key._reactInternals;
}

export function set(key, value) {
key._reactInternals = value;
}