@samitouri / QOS-React-2 / commits / 2f2a44007c

Improved Flowtypes in response to code review feedback

Brian Vaughn committed Dec 21, 2016 at 17:32 UTC 2f2a44007c1fdc1cd2726d79b2e3aba6bbfdb677
3 files changed +13 -15
src/renderers/shared/fiber/ReactFiberContext.js
+6 -4
@@ -37,7 +37,7 @@ if (__DEV__) {
37 }
38
39 let contextStackCursor : StackCursor<?Object> = createCursor((null: ?Object));
40 -let didPerformWorkStackCursor : StackCursor<?boolean> = createCursor((null: ?boolean));
40 +let didPerformWorkStackCursor : StackCursor<boolean> = createCursor(false);
41
42 function getUnmaskedContext() {
43 return contextStackCursor.current || emptyObject;
@@ -66,7 +66,7 @@ exports.getMaskedContext = function(workInProgress : Fiber) {
66 };
67
68 exports.hasContextChanged = function() : boolean {
69 - return Boolean(didPerformWorkStackCursor.current);
69 + return didPerformWorkStackCursor.current;
70 };
71
72 function isContextProvider(fiber : Fiber) : boolean {
@@ -136,8 +136,10 @@ exports.pushContextProvider = function(workInProgress : Fiber, didPerformWork :
136 };
137
138 exports.resetContext = function() : void {
139 - reset(contextStackCursor);
140 - reset(didPerformWorkStackCursor);
139 + reset();
140 +
141 + contextStackCursor.current = null;
142 + didPerformWorkStackCursor.current = false;
143 };
144
145 exports.findCurrentUnmaskedContext = function(fiber: Fiber) : Object {
src/renderers/shared/fiber/ReactFiberHostContext.js
+4 -2
@@ -114,8 +114,10 @@ module.exports = function<T, P, I, TI, C, CX>(
114 }
115
116 function resetHostContainer() {
117 - reset(contextStackCursor);
118 - reset(rootInstanceStackCursor);
117 + reset();
118 +
119 + contextStackCursor.current = null;
120 + rootInstanceStackCursor.current = null;
121 }
122
123 return {
src/renderers/shared/fiber/ReactFiberStack.js
+3 -9
@@ -55,9 +55,7 @@ exports.pop = function<T>(
55 }
56 }
57
58 - cursor.current = index > 0
59 - ? valueStack[index]
60 - : (null : any);
58 + cursor.current = valueStack[index];
59
60 valueStack[index] = null;
61
@@ -70,7 +68,7 @@ exports.pop = function<T>(
68
69 exports.push = function<T>(
70 cursor : StackCursor<T>,
73 - value : any,
71 + value : T,
72 fiber: Fiber,
73 ) : void {
74 index++;
@@ -84,9 +82,7 @@ exports.push = function<T>(
82 cursor.current = value;
83 };
84
87 -exports.reset = function<T>(
88 - cursor : StackCursor<T>,
89 -) : void {
85 +exports.reset = function() : void {
86 while (index > -1) {
87 valueStack[index] = null;
88
@@ -96,6 +92,4 @@ exports.reset = function<T>(
92
93 index--;
94 }
99 -
100 - cursor.current = (null : any);
95 };