1212
1313'use strict' ;
1414
15+ import type { Element } from 'React' ;
1516import type { Fiber } from 'ReactFiber' ;
1617import type { ReactNodeList } from 'ReactTypes' ;
1718
1819const NativeMethodsMixin = require ( 'NativeMethodsMixin' ) ;
19- const ReactControlledComponent = require ( 'ReactControlledComponent' ) ;
2020const ReactFiberReconciler = require ( 'ReactFiberReconciler' ) ;
2121const ReactGenericBatching = require ( 'ReactGenericBatching' ) ;
22- const ReactInstanceMap = require ( 'ReactInstanceMap' ) ;
2322const ReactNativeAttributePayload = require ( 'ReactNativeAttributePayload' ) ;
2423const ReactNativeComponentTree = require ( 'ReactNativeComponentTree' ) ;
2524const ReactNativeInjection = require ( 'ReactNativeInjection' ) ;
@@ -30,38 +29,33 @@ const UIManager = require('UIManager');
3029
3130const deepFreezeAndThrowOnMutationInDev = require ( 'deepFreezeAndThrowOnMutationInDev' ) ;
3231const findNodeHandle = require ( 'findNodeHandle' ) ;
33- const invariant = require ( 'invariant' ) ;
3432
3533const { precacheFiberNode, uncacheFiberNode } = ReactNativeComponentTree ;
3634
3735ReactNativeInjection . inject ( ) ;
38- // ReactControlledComponent.injection.injectFiberControlledHostComponent(
39- // ReactNativeFiberComponent
40- // );
4136
42- type Container = mixed ;
43- type Props = mixed ;
44- type Instance = mixed ;
45- type TextInstance = mixed ;
37+ type Container = number ;
38+ type Props = Object ;
39+ type Instance = any ;
40+ type TextInstance = number ;
4641
4742function NativeHostComponent ( tag ) {
4843 this . _nativeTag = tag ;
4944 this . _children = [ ] ;
5045}
5146Object . assign ( NativeHostComponent . prototype , NativeMethodsMixin ) ;
5247
53- function recursivelyUncacheFiberNode ( node ) {
48+ function recursivelyUncacheFiberNode ( node : Instance | TextInstance ) {
5449 if ( typeof node === 'number' ) { // Leaf node (eg text)
5550 uncacheFiberNode ( node ) ;
5651 } else {
57- uncacheFiberNode ( node . _nativeTag ) ;
52+ uncacheFiberNode ( ( node : any ) . _nativeTag ) ;
5853
59- node . _children . forEach ( recursivelyUncacheFiberNode ) ;
54+ ( node : any ) . _children . forEach ( recursivelyUncacheFiberNode ) ;
6055 }
6156}
6257
6358const NativeRenderer = ReactFiberReconciler ( {
64-
6559 appendChild (
6660 parentInstance : Instance | Container ,
6761 child : Instance | TextInstance
@@ -70,17 +64,19 @@ const NativeRenderer = ReactFiberReconciler({
7064 // Root container
7165 UIManager . setChildren (
7266 parentInstance , // containerTag
73- [ child . _nativeTag ] // reactTags
67+ [ ( child : any ) . _nativeTag ] // reactTags
7468 ) ;
7569 } else {
76- parentInstance . _children . push ( child ) ;
70+ const children = parentInstance . _children ;
71+
72+ children . push ( child ) ;
7773
7874 UIManager . manageChildren (
7975 parentInstance . _nativeTag , // containerTag
8076 [ ] , // moveFromIndices
8177 [ ] , // moveToIndices
82- [ child . _nativeTag ] , // addChildReactTags
83- [ parentInstance . _children . length - 1 ] , // addAtIndices
78+ [ ( child : any ) . _nativeTag ] , // addChildReactTags
79+ [ children . length - 1 ] , // addAtIndices
8480 [ ] , // removeAtIndices
8581 ) ;
8682 }
@@ -115,16 +111,18 @@ const NativeRenderer = ReactFiberReconciler({
115111 ) : void {
116112 precacheFiberNode ( internalInstanceHandle , instance . _nativeTag ) ;
117113
114+ const viewConfig = ( instance : any ) . viewConfig ;
115+
118116 const updatePayload = ReactNativeAttributePayload . diff (
119117 oldProps ,
120118 newProps ,
121- instance . viewConfig . validAttributes
119+ viewConfig . validAttributes
122120 ) ;
123121
124122 UIManager . updateView (
125- instance . _nativeTag , // reactTag
126- instance . viewConfig . uiViewClassName , // viewName
127- updatePayload , // props
123+ ( instance : any ) . _nativeTag , // reactTag
124+ viewConfig . uiViewClassName , // viewName
125+ ( updatePayload : any ) , // props
128126 ) ;
129127 } ,
130128
@@ -155,7 +153,7 @@ const NativeRenderer = ReactFiberReconciler({
155153 tag , // reactTag
156154 viewConfig . uiViewClassName , // viewName
157155 rootContainerInstance , // rootTag
158- updatePayload // props
156+ ( updatePayload : any ) , // props
159157 ) ;
160158
161159 const component = new NativeHostComponent ( tag ) ;
@@ -216,30 +214,31 @@ const NativeRenderer = ReactFiberReconciler({
216214 child : Instance | TextInstance ,
217215 beforeChild : Instance | TextInstance
218216 ) : void {
219- const beforeChildIndex = parentInstance . _children . indexOf ( beforeChild ) ;
220- const index = parentInstance . _children . indexOf ( child ) ;
217+ const children = ( parentInstance : any ) . _children ;
218+ const beforeChildIndex = children . indexOf ( beforeChild ) ;
219+ const index = children . indexOf ( child ) ;
221220
222221 // Move existing child or add new child?
223222 if ( index >= 0 ) {
224- parentInstance . _children . splice ( index , 1 ) ;
225- parentInstance . _children . splice ( beforeChildIndex , 0 , child ) ;
223+ children . splice ( index , 1 ) ;
224+ children . splice ( beforeChildIndex , 0 , child ) ;
226225
227226 UIManager . manageChildren (
228- parentInstance . _nativeTag , // containerID
227+ ( parentInstance : any ) . _nativeTag , // containerID
229228 [ index ] , // moveFromIndices
230229 [ beforeChildIndex ] , // moveToIndices
231230 [ ] , // addChildReactTags
232231 [ ] , // addAtIndices
233232 [ ] , // removeAtIndices
234233 ) ;
235234 } else {
236- parentInstance . _children . splice ( beforeChildIndex , 0 , child ) ;
235+ children . splice ( beforeChildIndex , 0 , child ) ;
237236
238237 UIManager . manageChildren (
239- parentInstance . _nativeTag , // containerID
238+ ( parentInstance : any ) . _nativeTag , // containerID
240239 [ ] , // moveFromIndices
241240 [ ] , // moveToIndices
242- [ child . _nativeTag ] , // addChildReactTags
241+ [ ( child : any ) . _nativeTag ] , // addChildReactTags
243242 [ beforeChildIndex ] , // addAtIndices
244243 [ ] , // removeAtIndices
245244 ) ;
@@ -271,9 +270,10 @@ const NativeRenderer = ReactFiberReconciler({
271270 [ 0 ] , // removeAtIndices
272271 ) ;
273272 } else {
274- const index = parentInstance . _children . indexOf ( child ) ;
273+ const children = parentInstance . _children
274+ const index = children . indexOf ( child ) ;
275275
276- parentInstance . _children . splice ( index , 1 ) ;
276+ children . splice ( index , 1 ) ;
277277
278278 UIManager . manageChildren (
279279 parentInstance . _nativeTag , // containerID
@@ -324,7 +324,7 @@ findNodeHandle.injection.injectFindRootNodeID(
324324const ReactNative = {
325325 findNodeHandle,
326326
327- render ( element : React . Element < any > , containerTag : number , callback : ?Function ) {
327+ render ( element : Element < any > , containerTag : any , callback : ?Function ) {
328328 let root = roots . get ( containerTag ) ;
329329
330330 if ( ! root ) {
0 commit comments