Skip to content

Commit

Permalink
Improved Flowtypes in response to code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Dec 22, 2016
1 parent ea6530d commit 2f2a440
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
10 changes: 6 additions & 4 deletions src/renderers/shared/fiber/ReactFiberContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if (__DEV__) {
}

let contextStackCursor : StackCursor<?Object> = createCursor((null: ?Object));
let didPerformWorkStackCursor : StackCursor<?boolean> = createCursor((null: ?boolean));
let didPerformWorkStackCursor : StackCursor<boolean> = createCursor(false);

function getUnmaskedContext() {
return contextStackCursor.current || emptyObject;
Expand Down Expand Up @@ -66,7 +66,7 @@ exports.getMaskedContext = function(workInProgress : Fiber) {
};

exports.hasContextChanged = function() : boolean {
return Boolean(didPerformWorkStackCursor.current);
return didPerformWorkStackCursor.current;
};

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

exports.resetContext = function() : void {
reset(contextStackCursor);
reset(didPerformWorkStackCursor);
reset();

contextStackCursor.current = null;
didPerformWorkStackCursor.current = false;
};

exports.findCurrentUnmaskedContext = function(fiber: Fiber) : Object {
Expand Down
6 changes: 4 additions & 2 deletions src/renderers/shared/fiber/ReactFiberHostContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ module.exports = function<T, P, I, TI, C, CX>(
}

function resetHostContainer() {
reset(contextStackCursor);
reset(rootInstanceStackCursor);
reset();

contextStackCursor.current = null;
rootInstanceStackCursor.current = null;
}

return {
Expand Down
12 changes: 3 additions & 9 deletions src/renderers/shared/fiber/ReactFiberStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ exports.pop = function<T>(
}
}

cursor.current = index > 0
? valueStack[index]
: (null : any);
cursor.current = valueStack[index];

valueStack[index] = null;

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

exports.push = function<T>(
cursor : StackCursor<T>,
value : any,
value : T,
fiber: Fiber,
) : void {
index++;
Expand All @@ -84,9 +82,7 @@ exports.push = function<T>(
cursor.current = value;
};

exports.reset = function<T>(
cursor : StackCursor<T>,
) : void {
exports.reset = function() : void {
while (index > -1) {
valueStack[index] = null;

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

index--;
}

cursor.current = (null : any);
};

0 comments on commit 2f2a440

Please sign in to comment.