Skip to content

Commit 2f2a440

Browse files
author
Brian Vaughn
committed
Improved Flowtypes in response to code review feedback
1 parent ea6530d commit 2f2a440

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

src/renderers/shared/fiber/ReactFiberContext.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if (__DEV__) {
3737
}
3838

3939
let contextStackCursor : StackCursor<?Object> = createCursor((null: ?Object));
40-
let didPerformWorkStackCursor : StackCursor<?boolean> = createCursor((null: ?boolean));
40+
let didPerformWorkStackCursor : StackCursor<boolean> = createCursor(false);
4141

4242
function getUnmaskedContext() {
4343
return contextStackCursor.current || emptyObject;
@@ -66,7 +66,7 @@ exports.getMaskedContext = function(workInProgress : Fiber) {
6666
};
6767

6868
exports.hasContextChanged = function() : boolean {
69-
return Boolean(didPerformWorkStackCursor.current);
69+
return didPerformWorkStackCursor.current;
7070
};
7171

7272
function isContextProvider(fiber : Fiber) : boolean {
@@ -136,8 +136,10 @@ exports.pushContextProvider = function(workInProgress : Fiber, didPerformWork :
136136
};
137137

138138
exports.resetContext = function() : void {
139-
reset(contextStackCursor);
140-
reset(didPerformWorkStackCursor);
139+
reset();
140+
141+
contextStackCursor.current = null;
142+
didPerformWorkStackCursor.current = false;
141143
};
142144

143145
exports.findCurrentUnmaskedContext = function(fiber: Fiber) : Object {

src/renderers/shared/fiber/ReactFiberHostContext.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@ module.exports = function<T, P, I, TI, C, CX>(
114114
}
115115

116116
function resetHostContainer() {
117-
reset(contextStackCursor);
118-
reset(rootInstanceStackCursor);
117+
reset();
118+
119+
contextStackCursor.current = null;
120+
rootInstanceStackCursor.current = null;
119121
}
120122

121123
return {

src/renderers/shared/fiber/ReactFiberStack.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ exports.pop = function<T>(
5555
}
5656
}
5757

58-
cursor.current = index > 0
59-
? valueStack[index]
60-
: (null : any);
58+
cursor.current = valueStack[index];
6159

6260
valueStack[index] = null;
6361

@@ -70,7 +68,7 @@ exports.pop = function<T>(
7068

7169
exports.push = function<T>(
7270
cursor : StackCursor<T>,
73-
value : any,
71+
value : T,
7472
fiber: Fiber,
7573
) : void {
7674
index++;
@@ -84,9 +82,7 @@ exports.push = function<T>(
8482
cursor.current = value;
8583
};
8684

87-
exports.reset = function<T>(
88-
cursor : StackCursor<T>,
89-
) : void {
85+
exports.reset = function() : void {
9086
while (index > -1) {
9187
valueStack[index] = null;
9288

@@ -96,6 +92,4 @@ exports.reset = function<T>(
9692

9793
index--;
9894
}
99-
100-
cursor.current = (null : any);
10195
};

0 commit comments

Comments
 (0)