Skip to content

Commit c4b089b

Browse files
author
Brian Vaughn
committed
Tightened up Flow types, disabled ReactNativeFiber (for now), added/cleaned up some comments
1 parent 6677f67 commit c4b089b

File tree

7 files changed

+28
-15
lines changed

7 files changed

+28
-15
lines changed

flow/react-native-host-hooks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ declare module 'UIManager' {
3333
reactTag : number,
3434
viewName : string,
3535
rootTag : number,
36-
props : Object,
36+
props : ?Object,
3737
) : void;
3838
declare function manageChildren(
3939
containerTag : number,
@@ -56,7 +56,7 @@ declare module 'UIManager' {
5656
declare function updateView(
5757
reactTag : number,
5858
viewName : string,
59-
props : Object,
59+
props : ?Object,
6060
) : void;
6161
}
6262
declare module 'View' {

src/renderers/native/NativeMethodsMixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ var NativeMethodsMixin = {
152152
UIManager.updateView(
153153
(findNodeHandle(this) : any),
154154
this.viewConfig.uiViewClassName,
155-
(updatePayload : any)
155+
updatePayload,
156156
);
157157
},
158158

src/renderers/native/ReactNative.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
*/
1212
'use strict';
1313

14+
/** TODO (bvaughn) Enable Fiber experiement
1415
const ReactNativeFeatureFlags = require('ReactNativeFeatureFlags');
1516
1617
module.exports = ReactNativeFeatureFlags.useFiber
1718
? require('ReactNativeFiber')
1819
: require('ReactNativeStack');
20+
*/
21+
module.exports = require('ReactNativeStack');

src/renderers/native/ReactNativeBaseComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ ReactNativeBaseComponent.Mixin = {
112112
UIManager.updateView(
113113
this._rootNodeID,
114114
this.viewConfig.uiViewClassName,
115-
(updatePayload : any)
115+
updatePayload
116116
);
117117
}
118118

src/renderers/native/ReactNativeComponentTree.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ function precacheFiberNode(hostInst, tag) {
4444
}
4545

4646
function uncacheNode(inst) {
47-
// TODO (bvaughn) Clean up once Stack is deprecated
48-
var tag = inst._rootNodeID || inst.stateNode._nativeTag;
47+
var tag = inst._rootNodeID;
4948
if (tag) {
5049
delete instanceCache[tag];
5150
}

src/renderers/native/ReactNativeFiber.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ const UIManager = require('UIManager');
2929

3030
const deepFreezeAndThrowOnMutationInDev = require('deepFreezeAndThrowOnMutationInDev');
3131
const findNodeHandle = require('findNodeHandle');
32+
const invariant = require('invariant');
3233

3334
const { precacheFiberNode, uncacheFiberNode } = ReactNativeComponentTree;
3435

3536
ReactNativeInjection.inject();
3637

3738
type Container = number;
39+
type Instance = {
40+
_children: Array<Instance | number>,
41+
_nativeTag: number,
42+
};
3843
type Props = Object;
39-
type Instance = any;
4044
type TextInstance = number;
4145

4246
function NativeHostComponent(tag) {
@@ -123,7 +127,7 @@ const NativeRenderer = ReactFiberReconciler({
123127
UIManager.updateView(
124128
(instance : any)._nativeTag, // reactTag
125129
viewConfig.uiViewClassName, // viewName
126-
(updatePayload : any), // props
130+
updatePayload, // props
127131
);
128132
},
129133

@@ -154,7 +158,7 @@ const NativeRenderer = ReactFiberReconciler({
154158
tag, // reactTag
155159
viewConfig.uiViewClassName, // viewName
156160
rootContainerInstance, // rootTag
157-
(updatePayload : any), // props
161+
updatePayload, // props
158162
);
159163

160164
const component = new NativeHostComponent(tag);
@@ -215,7 +219,17 @@ const NativeRenderer = ReactFiberReconciler({
215219
child : Instance | TextInstance,
216220
beforeChild : Instance | TextInstance
217221
) : void {
222+
// TODO (bvaughn): Remove this check when...
223+
// We create a wrapper object for the container in ReactNative render()
224+
// Or we refactor to remove wrapper objects entirely.
225+
// For more info on pros/cons see PR #8560 description.
226+
invariant(
227+
!(typeof parentInstance === 'number'),
228+
'Container does not support insertBefore operation',
229+
);
230+
218231
const children = (parentInstance : any)._children;
232+
219233
const beforeChildIndex = children.indexOf(beforeChild);
220234
const index = children.indexOf(child);
221235

@@ -247,7 +261,7 @@ const NativeRenderer = ReactFiberReconciler({
247261
},
248262

249263
prepareForCommit() : void {
250-
// Noop?
264+
// Noop
251265
},
252266

253267
prepareUpdate(
@@ -292,11 +306,11 @@ const NativeRenderer = ReactFiberReconciler({
292306
},
293307

294308
resetAfterCommit() : void {
295-
// Noop?
309+
// Noop
296310
},
297311

298312
resetTextContent(instance : Instance) : void {
299-
// Noop?
313+
// Noop
300314
},
301315

302316
scheduleAnimationCallback: global.requestAnimationFrame,

src/renderers/native/ReactNativeStack.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@
1111
*/
1212
'use strict';
1313

14-
// Require ReactNativeDefaultInjection first for its side effects of setting up
15-
// the JS environment
1614
var ReactNativeComponentTree = require('ReactNativeComponentTree');
1715
var ReactNativeInjection = require('ReactNativeInjection');
1816
var ReactNativeStackInjection = require('ReactNativeStackInjection');
19-
2017
var ReactNativeMount = require('ReactNativeMount');
2118
var ReactUpdates = require('ReactUpdates');
2219

0 commit comments

Comments
 (0)