1515import type { Fiber } from 'ReactFiber' ;
1616import type { ReactNodeList } from 'ReactTypes' ;
1717
18- var NativeMethodsMixin = require ( 'NativeMethodsMixin' ) ;
19- var ReactControlledComponent = require ( 'ReactControlledComponent' ) ;
20- var ReactFiberReconciler = require ( 'ReactFiberReconciler' ) ;
21- var ReactGenericBatching = require ( 'ReactGenericBatching' ) ;
22- var ReactInstanceMap = require ( 'ReactInstanceMap' ) ;
23- var ReactNativeAttributePayload = require ( 'ReactNativeAttributePayload' ) ;
24- var ReactNativeComponentTree = require ( 'ReactNativeComponentTree' ) ;
25- var ReactNativeInjection = require ( 'ReactNativeInjection' ) ;
26- var ReactNativeTagHandles = require ( 'ReactNativeTagHandles' ) ;
27- var ReactNativeViewConfigRegistry = require ( 'ReactNativeViewConfigRegistry' ) ;
28- var ReactPortal = require ( 'ReactPortal' ) ;
29- var UIManager = require ( 'UIManager' ) ;
30-
31- var deepFreezeAndThrowOnMutationInDev = require ( 'deepFreezeAndThrowOnMutationInDev' ) ;
32- var findNodeHandle = require ( 'findNodeHandle' ) ;
33- var invariant = require ( 'invariant' ) ;
34-
35- var { precacheFiberNode, uncacheFiberNode } = ReactNativeComponentTree ;
18+ const NativeMethodsMixin = require ( 'NativeMethodsMixin' ) ;
19+ const ReactControlledComponent = require ( 'ReactControlledComponent' ) ;
20+ const ReactFiberReconciler = require ( 'ReactFiberReconciler' ) ;
21+ const ReactGenericBatching = require ( 'ReactGenericBatching' ) ;
22+ const ReactInstanceMap = require ( 'ReactInstanceMap' ) ;
23+ const ReactNativeAttributePayload = require ( 'ReactNativeAttributePayload' ) ;
24+ const ReactNativeComponentTree = require ( 'ReactNativeComponentTree' ) ;
25+ const ReactNativeInjection = require ( 'ReactNativeInjection' ) ;
26+ const ReactNativeTagHandles = require ( 'ReactNativeTagHandles' ) ;
27+ const ReactNativeViewConfigRegistry = require ( 'ReactNativeViewConfigRegistry' ) ;
28+ const ReactPortal = require ( 'ReactPortal' ) ;
29+ const UIManager = require ( 'UIManager' ) ;
30+
31+ const deepFreezeAndThrowOnMutationInDev = require ( 'deepFreezeAndThrowOnMutationInDev' ) ;
32+ const findNodeHandle = require ( 'findNodeHandle' ) ;
33+ const invariant = require ( 'invariant' ) ;
34+
35+ const { precacheFiberNode, uncacheFiberNode } = ReactNativeComponentTree ;
3636
3737ReactNativeInjection . inject ( ) ;
3838// ReactControlledComponent.injection.injectFiberControlledHostComponent(
@@ -60,7 +60,7 @@ function recursivelyUncacheFiberNode (node) {
6060 }
6161}
6262
63- var NativeRenderer = ReactFiberReconciler ( {
63+ const NativeRenderer = ReactFiberReconciler ( {
6464
6565 appendChild (
6666 parentInstance : Instance | Container ,
@@ -69,19 +69,19 @@ var NativeRenderer = ReactFiberReconciler({
6969 if ( typeof parentInstance === 'number' ) {
7070 // Root container
7171 UIManager . setChildren (
72- parentInstance ,
73- [ child . _nativeTag ]
72+ parentInstance , // containerTag
73+ [ child . _nativeTag ] // reactTags
7474 ) ;
7575 } else {
7676 parentInstance . _children . push ( child ) ;
7777
7878 UIManager . manageChildren (
79- parentInstance . _nativeTag ,
80- [ ] ,
81- [ ] ,
82- [ child . _nativeTag ] ,
83- [ parentInstance . _children . length - 1 ] ,
84- [ ] ,
79+ parentInstance . _nativeTag , // containerTag
80+ [ ] , // moveFromIndices
81+ [ ] , // moveToIndices
82+ [ child . _nativeTag ] , // addChildReactTags
83+ [ parentInstance . _children . length - 1 ] , // addAtIndices
84+ [ ] , // removeAtIndices
8585 ) ;
8686 }
8787 } ,
@@ -100,9 +100,9 @@ var NativeRenderer = ReactFiberReconciler({
100100 newText : string
101101 ) : void {
102102 UIManager. updateView (
103- textInstance ,
104- 'RCTRawText' ,
105- { text : newText } ,
103+ textInstance , // reactTag
104+ 'RCTRawText' , // viewName
105+ { text : newText } , // props
106106 ) ;
107107 } ,
108108
@@ -115,16 +115,16 @@ var NativeRenderer = ReactFiberReconciler({
115115 ) : void {
116116 precacheFiberNode ( internalInstanceHandle , instance . _nativeTag ) ;
117117
118- var updatePayload = ReactNativeAttributePayload . diff (
118+ const updatePayload = ReactNativeAttributePayload . diff (
119119 oldProps ,
120120 newProps ,
121121 instance . viewConfig . validAttributes
122122 ) ;
123123
124124 UIManager . updateView (
125- instance . _nativeTag ,
126- instance . viewConfig . uiViewClassName ,
127- updatePayload ,
125+ instance . _nativeTag , // reactTag
126+ instance . viewConfig . uiViewClassName , // viewName
127+ updatePayload , // props
128128 ) ;
129129 } ,
130130
@@ -135,27 +135,27 @@ var NativeRenderer = ReactFiberReconciler({
135135 hostContext : string | null ,
136136 internalInstanceHandle : Object
137137 ) : Instance {
138- var tag = ReactNativeTagHandles . allocateTag ( ) ;
139- var viewConfig = ReactNativeViewConfigRegistry . get ( type ) ;
138+ const tag = ReactNativeTagHandles . allocateTag ( ) ;
139+ const viewConfig = ReactNativeViewConfigRegistry . get ( type ) ;
140140
141141 if ( __DEV__ ) {
142- for ( var key in viewConfig . validAttributes ) {
142+ for ( let key in viewConfig . validAttributes ) {
143143 if ( props . hasOwnProperty ( key ) ) {
144144 deepFreezeAndThrowOnMutationInDev ( props [ key ] ) ;
145145 }
146146 }
147147 }
148148
149- var updatePayload = ReactNativeAttributePayload . create (
149+ const updatePayload = ReactNativeAttributePayload . create (
150150 props ,
151151 viewConfig . validAttributes
152152 ) ;
153153
154154 UIManager . createView (
155- tag ,
156- viewConfig . uiViewClassName ,
157- rootContainerInstance ,
158- updatePayload
155+ tag , // reactTag
156+ viewConfig . uiViewClassName , // viewName
157+ rootContainerInstance , // rootTag
158+ updatePayload // props
159159 ) ;
160160
161161 const component = new NativeHostComponent ( tag ) ;
@@ -171,13 +171,13 @@ var NativeRenderer = ReactFiberReconciler({
171171 rootContainerInstance : Container ,
172172 internalInstanceHandle : Object ,
173173 ) : TextInstance {
174- var tag = ReactNativeTagHandles . allocateTag ( ) ;
174+ const tag = ReactNativeTagHandles . allocateTag ( ) ;
175175
176176 UIManager . createView (
177- tag ,
178- 'RCTRawText' ,
179- rootContainerInstance ,
180- { text : text }
177+ tag , // reactTag
178+ 'RCTRawText' , // viewName
179+ rootContainerInstance , // rootTag
180+ { text : text } // props
181181 ) ;
182182
183183 precacheFiberNode ( internalInstanceHandle , tag ) ;
@@ -191,16 +191,16 @@ var NativeRenderer = ReactFiberReconciler({
191191 rootContainerInstance : Container ,
192192 ) : void {
193193 // Map from child objects to native tags.
194- // If we weren't mapping we would still need to pass a copy of the Array to prevent it from being frozen.
194+ // Either way we need to pass a copy of the Array to prevent it from being frozen.
195195 const nativeTags = parentInstance . _children . map (
196196 ( child ) => typeof child === 'number'
197197 ? child // Leaf node (eg text)
198198 : child . _nativeTag
199199 ) ;
200200
201201 UIManager . setChildren (
202- parentInstance . _nativeTag ,
203- nativeTags
202+ parentInstance . _nativeTag , // containerTag
203+ nativeTags // reactTags
204204 ) ;
205205 } ,
206206
@@ -225,23 +225,23 @@ var NativeRenderer = ReactFiberReconciler({
225225 parentInstance . _children . splice ( beforeChildIndex , 0 , child ) ;
226226
227227 UIManager . manageChildren (
228- parentInstance . _nativeTag ,
229- [ index ] ,
230- [ beforeChildIndex ] ,
231- [ ] ,
232- [ ] ,
233- [ ] ,
228+ parentInstance . _nativeTag , // containerID
229+ [ index ] , // moveFromIndices
230+ [ beforeChildIndex ] , // moveToIndices
231+ [ ] , // addChildReactTags
232+ [ ] , // addAtIndices
233+ [ ] , // removeAtIndices
234234 ) ;
235235 } else {
236236 parentInstance . _children . splice ( beforeChildIndex , 0 , child ) ;
237237
238238 UIManager . manageChildren (
239- parentInstance . _nativeTag ,
240- [ ] ,
241- [ ] ,
242- [ child . _nativeTag ] ,
243- [ beforeChildIndex ] ,
244- [ ] ,
239+ parentInstance . _nativeTag , // containerID
240+ [ ] , // moveFromIndices
241+ [ ] , // moveToIndices
242+ [ child . _nativeTag ] , // addChildReactTags
243+ [ beforeChildIndex ] , // addAtIndices
244+ [ ] , // removeAtIndices
245245 ) ;
246246 }
247247 } ,
@@ -263,25 +263,25 @@ var NativeRenderer = ReactFiberReconciler({
263263
264264 if ( typeof parentInstance === 'number' ) {
265265 UIManager . manageChildren (
266- parentInstance ,
267- [ ] ,
268- [ ] ,
269- [ ] ,
270- [ ] ,
271- [ 0 ] ,
266+ parentInstance , // containerID
267+ [ ] , // moveFromIndices
268+ [ ] , // moveToIndices
269+ [ ] , // addChildReactTags
270+ [ ] , // addAtIndices
271+ [ 0 ] , // removeAtIndices
272272 ) ;
273273 } else {
274274 const index = parentInstance . _children . indexOf ( child ) ;
275275
276276 parentInstance . _children . splice ( index , 1 ) ;
277277
278278 UIManager . manageChildren (
279- parentInstance . _nativeTag ,
280- [ ] ,
281- [ ] ,
282- [ ] ,
283- [ ] ,
284- [ index ] ,
279+ parentInstance . _nativeTag , // containerID
280+ [ ] , // moveFromIndices
281+ [ ] , // moveToIndices
282+ [ ] , // addChildReactTags
283+ [ ] , // addAtIndices
284+ [ index ] , // removeAtIndices
285285 ) ;
286286 }
287287 } ,
@@ -321,7 +321,7 @@ findNodeHandle.injection.injectFindRootNodeID(
321321 ( instance ) => instance . _nativeTag
322322) ;
323323
324- var ReactNative = {
324+ const ReactNative = {
325325 findNodeHandle,
326326
327327 render ( element : React . Element < any > , containerTag : number , callback : ?Function ) {
0 commit comments