React sync for revisions ab4280b...ad9544f

Reviewed By: bvaughn

Differential Revision: D7256390

fbshipit-source-id: 9fe1324da93cb8f4a7f478e1037944774b9b95ff
This commit is contained in:
Héctor Ramos 2018-03-14 08:47:36 -07:00 committed by Facebook Github Bot
parent a01ae8b68a
commit 4f8328bf2f
8 changed files with 434 additions and 287 deletions

View File

@ -1 +1 @@
ab4280b3e98dbb97d3e753083dab19879167c3f5
ad9544f48e58f2599a8ea0de1e9f4dd104db30bb

View File

@ -3622,6 +3622,11 @@ var ReactNativeComponent = (function(_React$Component) {
/**
* Removes focus. This is the opposite of `focus()`.
*/
/**
* Due to bugs in Flow's handling of React.createClass, some fields already
* declared in the base class need to be redeclared below.
*/
ReactNativeComponent.prototype.blur = function blur() {
TextInputState.blurTextInput(findNumericNodeHandleFiber(this));
};
@ -8327,11 +8332,11 @@ var rendererSigil = void 0;
function pushProvider(providerFiber) {
var context = providerFiber.type.context;
index$1 += 1;
changedBitsStack[index$1] = context.changedBits;
currentValueStack[index$1] = context.currentValue;
changedBitsStack[index$1] = context._changedBits;
currentValueStack[index$1] = context._currentValue;
stack[index$1] = providerFiber;
context.currentValue = providerFiber.pendingProps.value;
context.changedBits = providerFiber.stateNode;
context._currentValue = providerFiber.pendingProps.value;
context._changedBits = providerFiber.stateNode;
{
warning(
@ -8358,16 +8363,16 @@ function popProvider(providerFiber) {
stack[index$1] = null;
index$1 -= 1;
var context = providerFiber.type.context;
context.currentValue = currentValue;
context.changedBits = changedBits;
context._currentValue = currentValue;
context._changedBits = changedBits;
}
function resetProviderStack() {
for (var i = index$1; i > -1; i--) {
var providerFiber = stack[i];
var context = providerFiber.type.context;
context.currentValue = context.defaultValue;
context.changedBits = 0;
context._currentValue = context._defaultValue;
context._changedBits = 0;
changedBitsStack[i] = null;
currentValueStack[i] = null;
stack[i] = null;
@ -9149,48 +9154,70 @@ var ReactFiberBeginWork = function(
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
workInProgress.memoizedProps = newProps;
var newValue = newProps.value;
workInProgress.memoizedProps = newProps;
var changedBits = void 0;
if (oldProps === null) {
// Initial render
changedBits = MAX_SIGNED_31_BIT_INT;
} else {
var oldValue = oldProps.value;
// Use Object.is to compare the new context value to the old value.
// Inlined Object.is polyfill.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
if (
(oldValue === newValue &&
(oldValue !== 0 || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare
) {
// No change.
if (oldProps.value === newProps.value) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
changedBits = 0;
} else {
changedBits =
typeof context.calculateChangedBits === "function"
? context.calculateChangedBits(oldValue, newValue)
: MAX_SIGNED_31_BIT_INT;
{
warning(
(changedBits & MAX_SIGNED_31_BIT_INT) === changedBits,
"calculateChangedBits: Expected the return value to be a " +
"31-bit integer. Instead received: %s",
changedBits
);
}
changedBits |= 0;
var oldValue = oldProps.value;
// Use Object.is to compare the new context value to the old value.
// Inlined Object.is polyfill.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
if (
(oldValue === newValue &&
(oldValue !== 0 || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare
) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
changedBits = 0;
} else {
changedBits =
typeof context._calculateChangedBits === "function"
? context._calculateChangedBits(oldValue, newValue)
: MAX_SIGNED_31_BIT_INT;
{
warning(
(changedBits & MAX_SIGNED_31_BIT_INT) === changedBits,
"calculateChangedBits: Expected the return value to be a " +
"31-bit integer. Instead received: %s",
changedBits
);
}
changedBits |= 0;
if (changedBits !== 0) {
propagateContextChange(
workInProgress,
context,
changedBits,
renderExpirationTime
);
if (changedBits === 0) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
} else {
propagateContextChange(
workInProgress,
context,
changedBits,
renderExpirationTime
);
}
}
}
}
@ -9198,9 +9225,6 @@ var ReactFiberBeginWork = function(
workInProgress.stateNode = changedBits;
pushProvider(workInProgress);
if (oldProps !== null && oldProps.children === newProps.children) {
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
var newChildren = newProps.children;
reconcileChildren(current, workInProgress, newChildren);
return workInProgress.child;
@ -9213,11 +9237,28 @@ var ReactFiberBeginWork = function(
) {
var context = workInProgress.type;
var newProps = workInProgress.pendingProps;
var oldProps = workInProgress.memoizedProps;
var newValue = context.currentValue;
var changedBits = context.changedBits;
var newValue = context._currentValue;
var changedBits = context._changedBits;
if (changedBits !== 0) {
if (hasContextChanged()) {
// Normally we can bail out on props equality but if context has changed
// we don't do the bailout and we have to reuse existing props instead.
} else if (changedBits === 0 && oldProps === newProps) {
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
workInProgress.memoizedProps = newProps;
var observedBits = newProps.unstable_observedBits;
if (observedBits === undefined || observedBits === null) {
// Subscribe to all changes by default
observedBits = MAX_SIGNED_31_BIT_INT;
}
// Store the observedBits on the fiber's stateNode for quick access.
workInProgress.stateNode = observedBits;
if ((changedBits & observedBits) !== 0) {
// Context change propagation stops at matching consumers, for time-
// slicing. Continue the propagation here.
propagateContextChange(
@ -9226,24 +9267,20 @@ var ReactFiberBeginWork = function(
changedBits,
renderExpirationTime
);
} else if (oldProps !== null && oldProps.children === newProps.children) {
// No change. Bailout early if children are the same.
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
// Store the observedBits on the fiber's stateNode for quick access.
var observedBits = newProps.observedBits;
if (observedBits === undefined || observedBits === null) {
// Subscribe to all changes by default
observedBits = MAX_SIGNED_31_BIT_INT;
}
workInProgress.stateNode = observedBits;
var render = newProps.children;
if (typeof render !== "function") {
invariant(
false,
"A context consumer was rendered with multiple children, or a child that isn't a function. " +
"A context consumer expects a single child that is a function. " +
"If you did pass a function, make sure there is no trailing or leading whitespace around it."
{
warning(
typeof render === "function",
"A context consumer was rendered with multiple children, or a child " +
"that isn't a function. A context consumer expects a single child " +
"that is a function. If you did pass a function, make sure there " +
"is no trailing or leading whitespace around it."
);
}

View File

@ -3122,11 +3122,11 @@ var reconcileChildFibers = ChildReconciler(!0),
function pushProvider(providerFiber) {
var context = providerFiber.type.context;
index$1 += 1;
changedBitsStack[index$1] = context.changedBits;
currentValueStack[index$1] = context.currentValue;
changedBitsStack[index$1] = context._changedBits;
currentValueStack[index$1] = context._currentValue;
stack[index$1] = providerFiber;
context.currentValue = providerFiber.pendingProps.value;
context.changedBits = providerFiber.stateNode;
context._currentValue = providerFiber.pendingProps.value;
context._changedBits = providerFiber.stateNode;
}
function popProvider(providerFiber) {
var changedBits = changedBitsStack[index$1],
@ -3136,8 +3136,8 @@ function popProvider(providerFiber) {
stack[index$1] = null;
--index$1;
providerFiber = providerFiber.type.context;
providerFiber.currentValue = currentValue;
providerFiber.changedBits = changedBits;
providerFiber._currentValue = currentValue;
providerFiber._changedBits = changedBits;
}
function ReactFiberBeginWork(
config,
@ -3289,6 +3289,72 @@ function ReactFiberBeginWork(
fiber = nextFiber;
}
}
function updateContextProvider(
current,
workInProgress,
renderExpirationTime
) {
var context = workInProgress.type.context,
newProps = workInProgress.pendingProps,
oldProps = workInProgress.memoizedProps;
if (!didPerformWorkStackCursor.current && oldProps === newProps)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
var newValue = newProps.value;
workInProgress.memoizedProps = newProps;
if (null === oldProps) newValue = 1073741823;
else if (oldProps.value === newProps.value) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
newValue = 0;
} else {
var oldValue = oldProps.value;
if (
(oldValue === newValue &&
(0 !== oldValue || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue)
) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
newValue = 0;
} else if (
((newValue =
"function" === typeof context._calculateChangedBits
? context._calculateChangedBits(oldValue, newValue)
: 1073741823),
(newValue |= 0),
0 === newValue)
) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
} else
propagateContextChange(
workInProgress,
context,
newValue,
renderExpirationTime
);
}
workInProgress.stateNode = newValue;
pushProvider(workInProgress);
reconcileChildren(current, workInProgress, newProps.children);
return workInProgress.child;
}
function bailoutOnAlreadyFinishedWork(current, workInProgress) {
invariant(
null === current || workInProgress.child === current.child,
@ -3641,71 +3707,50 @@ function ReactFiberBeginWork(
current
);
case 13:
props = workInProgress.type.context;
fn = workInProgress.pendingProps;
unmaskedContext = workInProgress.memoizedProps;
if (didPerformWorkStackCursor.current || unmaskedContext !== fn) {
workInProgress.memoizedProps = fn;
updateQueue = fn.value;
if (null === unmaskedContext) updateQueue = 1073741823;
else {
var oldValue = unmaskedContext.value;
(oldValue === updateQueue &&
(0 !== oldValue || 1 / oldValue === 1 / updateQueue)) ||
(oldValue !== oldValue && updateQueue !== updateQueue)
? (updateQueue = 0)
: ((updateQueue =
"function" === typeof props.calculateChangedBits
? props.calculateChangedBits(oldValue, updateQueue)
: 1073741823),
(updateQueue |= 0),
0 !== updateQueue &&
propagateContextChange(
workInProgress,
props,
updateQueue,
renderExpirationTime
));
}
workInProgress.stateNode = updateQueue;
pushProvider(workInProgress);
null !== unmaskedContext && unmaskedContext.children === fn.children
? (current = bailoutOnAlreadyFinishedWork(
current,
workInProgress
))
: (reconcileChildren(current, workInProgress, fn.children),
(current = workInProgress.child));
} else
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
(current = bailoutOnAlreadyFinishedWork(current, workInProgress));
return current;
return updateContextProvider(
current,
workInProgress,
renderExpirationTime
);
case 12:
unmaskedContext = workInProgress.type;
fn = workInProgress.pendingProps;
props = unmaskedContext.currentValue;
updateQueue = unmaskedContext.changedBits;
0 !== updateQueue &&
propagateContextChange(
workInProgress,
unmaskedContext,
updateQueue,
renderExpirationTime
);
renderExpirationTime = fn.observedBits;
if (void 0 === renderExpirationTime || null === renderExpirationTime)
renderExpirationTime = 1073741823;
workInProgress.stateNode = renderExpirationTime;
renderExpirationTime = fn.children;
"function" !== typeof renderExpirationTime &&
invariant(
!1,
"A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it."
);
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
return workInProgress.child;
a: {
fn = workInProgress.type;
unmaskedContext = workInProgress.pendingProps;
updateQueue = workInProgress.memoizedProps;
props = fn._currentValue;
var changedBits = fn._changedBits;
if (
didPerformWorkStackCursor.current ||
0 !== changedBits ||
updateQueue !== unmaskedContext
) {
workInProgress.memoizedProps = unmaskedContext;
var observedBits = unmaskedContext.unstable_observedBits;
if (void 0 === observedBits || null === observedBits)
observedBits = 1073741823;
workInProgress.stateNode = observedBits;
if (0 !== (changedBits & observedBits))
propagateContextChange(
workInProgress,
fn,
changedBits,
renderExpirationTime
);
else if (
null !== updateQueue &&
updateQueue.children === unmaskedContext.children
) {
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
break a;
}
renderExpirationTime = unmaskedContext.children;
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
current = workInProgress.child;
} else
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
}
return current;
default:
invariant(
!1,
@ -4581,8 +4626,8 @@ function ReactFiberScheduler(config) {
resetHostContainer();
for (var i = index$1; -1 < i; i--) {
var context = stack[i].type.context;
context.currentValue = context.defaultValue;
context.changedBits = 0;
context._currentValue = context._defaultValue;
context._changedBits = 0;
changedBitsStack[i] = null;
currentValueStack[i] = null;
stack[i] = null;

View File

@ -3968,6 +3968,11 @@ var ReactNativeComponent = (function(_React$Component) {
/**
* Removes focus. This is the opposite of `focus()`.
*/
/**
* Due to bugs in Flow's handling of React.createClass, some fields already
* declared in the base class need to be redeclared below.
*/
ReactNativeComponent.prototype.blur = function blur() {
TextInputState.blurTextInput(findNumericNodeHandleFiber(this));
};
@ -8585,11 +8590,11 @@ var rendererSigil = void 0;
function pushProvider(providerFiber) {
var context = providerFiber.type.context;
index$1 += 1;
changedBitsStack[index$1] = context.changedBits;
currentValueStack[index$1] = context.currentValue;
changedBitsStack[index$1] = context._changedBits;
currentValueStack[index$1] = context._currentValue;
stack[index$1] = providerFiber;
context.currentValue = providerFiber.pendingProps.value;
context.changedBits = providerFiber.stateNode;
context._currentValue = providerFiber.pendingProps.value;
context._changedBits = providerFiber.stateNode;
{
warning(
@ -8616,16 +8621,16 @@ function popProvider(providerFiber) {
stack[index$1] = null;
index$1 -= 1;
var context = providerFiber.type.context;
context.currentValue = currentValue;
context.changedBits = changedBits;
context._currentValue = currentValue;
context._changedBits = changedBits;
}
function resetProviderStack() {
for (var i = index$1; i > -1; i--) {
var providerFiber = stack[i];
var context = providerFiber.type.context;
context.currentValue = context.defaultValue;
context.changedBits = 0;
context._currentValue = context._defaultValue;
context._changedBits = 0;
changedBitsStack[i] = null;
currentValueStack[i] = null;
stack[i] = null;
@ -9407,48 +9412,70 @@ var ReactFiberBeginWork = function(
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
workInProgress.memoizedProps = newProps;
var newValue = newProps.value;
workInProgress.memoizedProps = newProps;
var changedBits = void 0;
if (oldProps === null) {
// Initial render
changedBits = MAX_SIGNED_31_BIT_INT;
} else {
var oldValue = oldProps.value;
// Use Object.is to compare the new context value to the old value.
// Inlined Object.is polyfill.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
if (
(oldValue === newValue &&
(oldValue !== 0 || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare
) {
// No change.
if (oldProps.value === newProps.value) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
changedBits = 0;
} else {
changedBits =
typeof context.calculateChangedBits === "function"
? context.calculateChangedBits(oldValue, newValue)
: MAX_SIGNED_31_BIT_INT;
{
warning(
(changedBits & MAX_SIGNED_31_BIT_INT) === changedBits,
"calculateChangedBits: Expected the return value to be a " +
"31-bit integer. Instead received: %s",
changedBits
);
}
changedBits |= 0;
var oldValue = oldProps.value;
// Use Object.is to compare the new context value to the old value.
// Inlined Object.is polyfill.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
if (
(oldValue === newValue &&
(oldValue !== 0 || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare
) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
changedBits = 0;
} else {
changedBits =
typeof context._calculateChangedBits === "function"
? context._calculateChangedBits(oldValue, newValue)
: MAX_SIGNED_31_BIT_INT;
{
warning(
(changedBits & MAX_SIGNED_31_BIT_INT) === changedBits,
"calculateChangedBits: Expected the return value to be a " +
"31-bit integer. Instead received: %s",
changedBits
);
}
changedBits |= 0;
if (changedBits !== 0) {
propagateContextChange(
workInProgress,
context,
changedBits,
renderExpirationTime
);
if (changedBits === 0) {
// No change. Bailout early if children are the same.
if (oldProps.children === newProps.children) {
workInProgress.stateNode = 0;
pushProvider(workInProgress);
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
} else {
propagateContextChange(
workInProgress,
context,
changedBits,
renderExpirationTime
);
}
}
}
}
@ -9456,9 +9483,6 @@ var ReactFiberBeginWork = function(
workInProgress.stateNode = changedBits;
pushProvider(workInProgress);
if (oldProps !== null && oldProps.children === newProps.children) {
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
var newChildren = newProps.children;
reconcileChildren(current, workInProgress, newChildren);
return workInProgress.child;
@ -9471,11 +9495,28 @@ var ReactFiberBeginWork = function(
) {
var context = workInProgress.type;
var newProps = workInProgress.pendingProps;
var oldProps = workInProgress.memoizedProps;
var newValue = context.currentValue;
var changedBits = context.changedBits;
var newValue = context._currentValue;
var changedBits = context._changedBits;
if (changedBits !== 0) {
if (hasContextChanged()) {
// Normally we can bail out on props equality but if context has changed
// we don't do the bailout and we have to reuse existing props instead.
} else if (changedBits === 0 && oldProps === newProps) {
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
workInProgress.memoizedProps = newProps;
var observedBits = newProps.unstable_observedBits;
if (observedBits === undefined || observedBits === null) {
// Subscribe to all changes by default
observedBits = MAX_SIGNED_31_BIT_INT;
}
// Store the observedBits on the fiber's stateNode for quick access.
workInProgress.stateNode = observedBits;
if ((changedBits & observedBits) !== 0) {
// Context change propagation stops at matching consumers, for time-
// slicing. Continue the propagation here.
propagateContextChange(
@ -9484,24 +9525,20 @@ var ReactFiberBeginWork = function(
changedBits,
renderExpirationTime
);
} else if (oldProps !== null && oldProps.children === newProps.children) {
// No change. Bailout early if children are the same.
return bailoutOnAlreadyFinishedWork(current, workInProgress);
}
// Store the observedBits on the fiber's stateNode for quick access.
var observedBits = newProps.observedBits;
if (observedBits === undefined || observedBits === null) {
// Subscribe to all changes by default
observedBits = MAX_SIGNED_31_BIT_INT;
}
workInProgress.stateNode = observedBits;
var render = newProps.children;
if (typeof render !== "function") {
invariant(
false,
"A context consumer was rendered with multiple children, or a child that isn't a function. " +
"A context consumer expects a single child that is a function. " +
"If you did pass a function, make sure there is no trailing or leading whitespace around it."
{
warning(
typeof render === "function",
"A context consumer was rendered with multiple children, or a child " +
"that isn't a function. A context consumer expects a single child " +
"that is a function. If you did pass a function, make sure there " +
"is no trailing or leading whitespace around it."
);
}

View File

@ -3376,11 +3376,11 @@ var reconcileChildFibers = ChildReconciler(!0),
function pushProvider(providerFiber) {
var context = providerFiber.type.context;
index$1 += 1;
changedBitsStack[index$1] = context.changedBits;
currentValueStack[index$1] = context.currentValue;
changedBitsStack[index$1] = context._changedBits;
currentValueStack[index$1] = context._currentValue;
stack[index$1] = providerFiber;
context.currentValue = providerFiber.pendingProps.value;
context.changedBits = providerFiber.stateNode;
context._currentValue = providerFiber.pendingProps.value;
context._changedBits = providerFiber.stateNode;
}
function popProvider(providerFiber) {
var changedBits = changedBitsStack[index$1],
@ -3390,8 +3390,8 @@ function popProvider(providerFiber) {
stack[index$1] = null;
--index$1;
providerFiber = providerFiber.type.context;
providerFiber.currentValue = currentValue;
providerFiber.changedBits = changedBits;
providerFiber._currentValue = currentValue;
providerFiber._changedBits = changedBits;
}
function ReactFiberBeginWork(
config,
@ -3552,6 +3552,72 @@ function ReactFiberBeginWork(
fiber = nextFiber;
}
}
function updateContextProvider(
current,
workInProgress,
renderExpirationTime
) {
var context = workInProgress.type.context,
newProps = workInProgress.pendingProps,
oldProps = workInProgress.memoizedProps;
if (!didPerformWorkStackCursor.current && oldProps === newProps)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
var newValue = newProps.value;
workInProgress.memoizedProps = newProps;
if (null === oldProps) newValue = 1073741823;
else if (oldProps.value === newProps.value) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
newValue = 0;
} else {
var oldValue = oldProps.value;
if (
(oldValue === newValue &&
(0 !== oldValue || 1 / oldValue === 1 / newValue)) ||
(oldValue !== oldValue && newValue !== newValue)
) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
newValue = 0;
} else if (
((newValue =
"function" === typeof context._calculateChangedBits
? context._calculateChangedBits(oldValue, newValue)
: 1073741823),
(newValue |= 0),
0 === newValue)
) {
if (oldProps.children === newProps.children)
return (
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
bailoutOnAlreadyFinishedWork(current, workInProgress)
);
} else
propagateContextChange(
workInProgress,
context,
newValue,
renderExpirationTime
);
}
workInProgress.stateNode = newValue;
pushProvider(workInProgress);
reconcileChildren(current, workInProgress, newProps.children);
return workInProgress.child;
}
function bailoutOnAlreadyFinishedWork(current, workInProgress) {
invariant(
null === current || workInProgress.child === current.child,
@ -3904,71 +3970,50 @@ function ReactFiberBeginWork(
current
);
case 13:
props = workInProgress.type.context;
fn = workInProgress.pendingProps;
unmaskedContext = workInProgress.memoizedProps;
if (didPerformWorkStackCursor.current || unmaskedContext !== fn) {
workInProgress.memoizedProps = fn;
updateQueue = fn.value;
if (null === unmaskedContext) updateQueue = 1073741823;
else {
var oldValue = unmaskedContext.value;
(oldValue === updateQueue &&
(0 !== oldValue || 1 / oldValue === 1 / updateQueue)) ||
(oldValue !== oldValue && updateQueue !== updateQueue)
? (updateQueue = 0)
: ((updateQueue =
"function" === typeof props.calculateChangedBits
? props.calculateChangedBits(oldValue, updateQueue)
: 1073741823),
(updateQueue |= 0),
0 !== updateQueue &&
propagateContextChange(
workInProgress,
props,
updateQueue,
renderExpirationTime
));
}
workInProgress.stateNode = updateQueue;
pushProvider(workInProgress);
null !== unmaskedContext && unmaskedContext.children === fn.children
? (current = bailoutOnAlreadyFinishedWork(
current,
workInProgress
))
: (reconcileChildren(current, workInProgress, fn.children),
(current = workInProgress.child));
} else
(workInProgress.stateNode = 0),
pushProvider(workInProgress),
(current = bailoutOnAlreadyFinishedWork(current, workInProgress));
return current;
return updateContextProvider(
current,
workInProgress,
renderExpirationTime
);
case 12:
unmaskedContext = workInProgress.type;
fn = workInProgress.pendingProps;
props = unmaskedContext.currentValue;
updateQueue = unmaskedContext.changedBits;
0 !== updateQueue &&
propagateContextChange(
workInProgress,
unmaskedContext,
updateQueue,
renderExpirationTime
);
renderExpirationTime = fn.observedBits;
if (void 0 === renderExpirationTime || null === renderExpirationTime)
renderExpirationTime = 1073741823;
workInProgress.stateNode = renderExpirationTime;
renderExpirationTime = fn.children;
"function" !== typeof renderExpirationTime &&
invariant(
!1,
"A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it."
);
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
return workInProgress.child;
a: {
fn = workInProgress.type;
unmaskedContext = workInProgress.pendingProps;
updateQueue = workInProgress.memoizedProps;
props = fn._currentValue;
var changedBits = fn._changedBits;
if (
didPerformWorkStackCursor.current ||
0 !== changedBits ||
updateQueue !== unmaskedContext
) {
workInProgress.memoizedProps = unmaskedContext;
var observedBits = unmaskedContext.unstable_observedBits;
if (void 0 === observedBits || null === observedBits)
observedBits = 1073741823;
workInProgress.stateNode = observedBits;
if (0 !== (changedBits & observedBits))
propagateContextChange(
workInProgress,
fn,
changedBits,
renderExpirationTime
);
else if (
null !== updateQueue &&
updateQueue.children === unmaskedContext.children
) {
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
break a;
}
renderExpirationTime = unmaskedContext.children;
renderExpirationTime = renderExpirationTime(props);
reconcileChildren(current, workInProgress, renderExpirationTime);
current = workInProgress.child;
} else
current = bailoutOnAlreadyFinishedWork(current, workInProgress);
}
return current;
default:
invariant(
!1,
@ -4977,8 +5022,8 @@ function ReactFiberScheduler(config) {
resetHostContainer();
for (var i = index$1; -1 < i; i--) {
var context = stack[i].type.context;
context.currentValue = context.defaultValue;
context.changedBits = 0;
context._currentValue = context._defaultValue;
context._changedBits = 0;
changedBitsStack[i] = null;
currentValueStack[i] = null;
stack[i] = null;

View File

@ -9,8 +9,6 @@
*/
'use strict';
const BatchedBridge = require('BatchedBridge');
// TODO @sema: Adjust types
import type {ReactNativeType} from 'ReactNativeTypes';
@ -22,6 +20,4 @@ if (__DEV__) {
ReactFabric = require('ReactFabric-prod');
}
BatchedBridge.registerCallableModule('ReactFabric', ReactFabric);
module.exports = (ReactFabric: ReactNativeType);

View File

@ -86,27 +86,12 @@ type SecretInternalsType = {
// And how much information to fill in for the above types.
};
declare class ReactNativeComponent<Props, State = void>
extends React$Component<Props, State> {
blur(): void,
focus(): void,
measure(callback: MeasureOnSuccessCallback): void,
measureInWindow(callback: MeasureInWindowOnSuccessCallback): void,
measureLayout(
relativeToNativeNode: number,
onSuccess: MeasureLayoutOnSuccessCallback,
onFail: () => void,
): void,
setNativeProps(nativeProps: Object): void,
}
/**
* Flat ReactNative renderer bundles are too big for Flow to parse efficiently.
* Provide minimal Flow typing for the high-level RN API and call it a day.
*/
export type ReactNativeType = {
NativeComponent: typeof ReactNativeComponent,
NativeComponent: any,
findNodeHandle(componentOrHandle: any): ?number,
render(
element: React$Element<any>,

View File

@ -80,10 +80,12 @@ export type ReactContext<T> = {
$$typeof: Symbol | number,
Consumer: ReactContext<T>,
Provider: ReactProviderType<T>,
calculateChangedBits: ((a: T, b: T) => number) | null,
defaultValue: T,
currentValue: T,
changedBits: number,
_calculateChangedBits: ((a: T, b: T) => number) | null,
_defaultValue: T,
_currentValue: T,
_changedBits: number,
// DEV only
_currentRenderer?: Object | null,