mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Add support for setChildren
Summary: This adds support for UIManager.setChildren on Android like D2757388 added for iOS. Reviewed By: andreicoman11 Differential Revision: D3235369 fb-gh-sync-id: b538556ec4abdb606f9be26d1b74734046bca0cd fbshipit-source-id: b538556ec4abdb606f9be26d1b74734046bca0cd
This commit is contained in:
committed by
Facebook Github Bot 1
parent
3f0207d7b5
commit
3a5457cd7c
@@ -14,35 +14,6 @@
|
||||
var UIManager = require('NativeModules').UIManager;
|
||||
var findNodeHandle = require('findNodeHandle');
|
||||
|
||||
if (!UIManager.setChildren) {
|
||||
|
||||
/**
|
||||
* Index cache (used by setChildren())
|
||||
*/
|
||||
UIManager._cachedIndexArray = function(size) {
|
||||
var cachedResult = this._cachedIndexArray._cache[size];
|
||||
if (!cachedResult) {
|
||||
var arr = [];
|
||||
for (var i = 0; i < size; i++) {
|
||||
arr[i] = i;
|
||||
}
|
||||
this._cachedIndexArray._cache[size] = arr;
|
||||
return arr;
|
||||
} else {
|
||||
return cachedResult;
|
||||
}
|
||||
};
|
||||
UIManager._cachedIndexArray._cache = {};
|
||||
|
||||
/**
|
||||
* Fallback setChildren() implementation for Android
|
||||
*/
|
||||
UIManager.setChildren = function(containerTag, createdTags) {
|
||||
var indexes = this._cachedIndexArray(createdTags.length);
|
||||
UIManager.manageChildren(containerTag, null, null, createdTags, indexes, null);
|
||||
};
|
||||
}
|
||||
|
||||
const _takeSnapshot = UIManager.takeSnapshot;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user