React sync for revisions ad9544f...ced176e

Reviewed By: sebmarkbage

Differential Revision: D7281277

fbshipit-source-id: 75a638114cf2a65a5c973dbdf218f6d3ba042cc4
This commit is contained in:
Brian Vaughn 2018-03-14 23:23:11 -07:00 committed by Facebook Github Bot
parent d678058402
commit 22004db819
7 changed files with 153 additions and 67 deletions

View File

@ -1 +1 @@
ad9544f48e58f2599a8ea0de1e9f4dd104db30bb
ced176edb7605a25e916895fd060f3943c647fee

View File

@ -810,6 +810,7 @@ var Fragment = 10;
var Mode = 11;
var ContextConsumer = 12;
var ContextProvider = 13;
var ForwardRef = 14;
function getParent(inst) {
do {
@ -2356,6 +2357,9 @@ var REACT_CONTEXT_TYPE = hasSymbol ? Symbol["for"]("react.context") : 0xeace;
var REACT_ASYNC_MODE_TYPE = hasSymbol
? Symbol["for"]("react.async_mode")
: 0xeacf;
var REACT_FORWARD_REF_TYPE = hasSymbol
? Symbol["for"]("react.forward_ref")
: 0xead0;
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = "@@iterator";
@ -2637,7 +2641,7 @@ var TouchHistoryMath = {
// TODO: this is special because it gets imported during build.
var ReactVersion = "16.3.0-alpha.1";
var ReactVersion = "16.3.0-alpha.2";
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
@ -5242,6 +5246,9 @@ function createFiberFromElement(element, mode, expirationTime) {
// This is a consumer
fiberTag = ContextConsumer;
break;
case REACT_FORWARD_REF_TYPE:
fiberTag = ForwardRef;
break;
default:
if (typeof type.tag === "number") {
// Currently assumed to be a continuation and therefore is a
@ -6834,20 +6841,20 @@ var ReactFiberClassComponent = function(
// In order to support react-lifecycles-compat polyfilled components,
// Unsafe lifecycles should not be invoked for any component with the new gDSFP.
if (
(typeof instance.UNSAFE_componentWillUpdate === "function" ||
typeof instance.componentWillUpdate === "function") &&
(typeof instance.UNSAFE_componentWillMount === "function" ||
typeof instance.componentWillMount === "function") &&
typeof ctor.getDerivedStateFromProps !== "function"
) {
startPhaseTimer(workInProgress, "componentWillUpdate");
if (typeof instance.componentWillUpdate === "function") {
instance.componentWillUpdate(newProps, newState, newContext);
startPhaseTimer(workInProgress, "componentWillMount");
if (typeof instance.componentWillMount === "function") {
instance.componentWillMount();
}
if (typeof instance.UNSAFE_componentWillUpdate === "function") {
instance.UNSAFE_componentWillUpdate(newProps, newState, newContext);
if (typeof instance.UNSAFE_componentWillMount === "function") {
instance.UNSAFE_componentWillMount();
}
stopPhaseTimer();
}
if (typeof instance.componentDidUpdate === "function") {
if (typeof instance.componentDidMount === "function") {
workInProgress.effectTag |= Update;
}
} else {
@ -8467,6 +8474,14 @@ var ReactFiberBeginWork = function(
}
}
function updateForwardRef(current, workInProgress) {
var render = workInProgress.type.render;
var nextChildren = render(workInProgress.pendingProps, workInProgress.ref);
reconcileChildren(current, workInProgress, nextChildren);
memoizeProps(workInProgress, nextChildren);
return workInProgress.child;
}
function updateFragment(current, workInProgress) {
var nextChildren = workInProgress.pendingProps;
if (hasContextChanged()) {
@ -9420,6 +9435,8 @@ var ReactFiberBeginWork = function(
workInProgress,
renderExpirationTime
);
case ForwardRef:
return updateForwardRef(current, workInProgress);
case Fragment:
return updateFragment(current, workInProgress);
case Mode:
@ -9972,6 +9989,8 @@ var ReactFiberCompleteWork = function(config, hostContext, hydrationContext) {
case ReturnComponent:
// Does nothing.
return null;
case ForwardRef:
return null;
case Fragment:
return null;
case Mode:
@ -10277,7 +10296,7 @@ var ReactFiberCommitWork = function(
}
}
} else {
ref.value = null;
ref.current = null;
}
}
}
@ -10442,7 +10461,19 @@ var ReactFiberCommitWork = function(
if (typeof ref === "function") {
ref(instanceToUse);
} else {
ref.value = instanceToUse;
{
if (!ref.hasOwnProperty("current")) {
warning(
false,
"Unexpected ref object provided for %s. " +
"Use either a ref-setter function or Reacte.createRef().%s",
getComponentName(finishedWork),
getStackAddendumByWorkInProgressFiber(finishedWork)
);
}
}
ref.current = instanceToUse;
}
}
}
@ -10453,7 +10484,7 @@ var ReactFiberCommitWork = function(
if (typeof currentRef === "function") {
currentRef(null);
} else {
currentRef.value = null;
currentRef.current = null;
}
}
}

View File

@ -945,6 +945,9 @@ var hasSymbol = "function" === typeof Symbol && Symbol["for"],
REACT_PROVIDER_TYPE = hasSymbol ? Symbol["for"]("react.provider") : 60109,
REACT_CONTEXT_TYPE = hasSymbol ? Symbol["for"]("react.context") : 60110,
REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol["for"]("react.async_mode") : 60111,
REACT_FORWARD_REF_TYPE = hasSymbol
? Symbol["for"]("react.forward_ref")
: 60112,
MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "undefined" === typeof maybeIterable)
@ -1843,6 +1846,9 @@ function createFiberFromElement(element, mode, expirationTime) {
case REACT_CONTEXT_TYPE:
fiberTag = 12;
break;
case REACT_FORWARD_REF_TYPE:
fiberTag = 14;
break;
default:
if ("number" === typeof type.tag)
return (
@ -2312,22 +2318,14 @@ function ReactFiberClassComponent(
renderExpirationTime,
newUnmaskedContext
))
? (("function" !== typeof instance.UNSAFE_componentWillUpdate &&
"function" !== typeof instance.componentWillUpdate) ||
? (("function" !== typeof instance.UNSAFE_componentWillMount &&
"function" !== typeof instance.componentWillMount) ||
"function" === typeof ctor.getDerivedStateFromProps ||
("function" === typeof instance.componentWillUpdate &&
instance.componentWillUpdate(
newProps,
renderExpirationTime,
newUnmaskedContext
),
"function" === typeof instance.UNSAFE_componentWillUpdate &&
instance.UNSAFE_componentWillUpdate(
newProps,
renderExpirationTime,
newUnmaskedContext
)),
"function" === typeof instance.componentDidUpdate &&
("function" === typeof instance.componentWillMount &&
instance.componentWillMount(),
"function" === typeof instance.UNSAFE_componentWillMount &&
instance.UNSAFE_componentWillMount()),
"function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4))
: ("function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4),
@ -3669,6 +3667,17 @@ function ReactFiberBeginWork(
)),
current
);
case 14:
return (
(renderExpirationTime = workInProgress.type.render),
(renderExpirationTime = renderExpirationTime(
workInProgress.pendingProps,
workInProgress.ref
)),
reconcileChildren(current, workInProgress, renderExpirationTime),
(workInProgress.memoizedProps = renderExpirationTime),
workInProgress.child
);
case 10:
return (
(renderExpirationTime = workInProgress.pendingProps),
@ -4058,6 +4067,8 @@ function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
return (workInProgress.tag = 7), null;
case 9:
return null;
case 14:
return null;
case 10:
return null;
case 11:
@ -4191,7 +4202,7 @@ function ReactFiberCommitWork(
} catch (refError) {
captureError(current, refError);
}
else ref.value = null;
else ref.current = null;
}
function commitLifeCycles(finishedRoot, current, finishedWork) {
switch (finishedWork.tag) {
@ -4305,13 +4316,15 @@ function ReactFiberCommitWork(
}
"function" === typeof ref
? ref(finishedWork)
: (ref.value = finishedWork);
: (ref.current = finishedWork);
}
}
function commitDetachRef(current) {
current = current.ref;
null !== current &&
("function" === typeof current ? current(null) : (current.value = null));
("function" === typeof current
? current(null)
: (current.current = null));
}
function commitNestedUnmounts(root) {
for (var node = root; ; ) {
@ -5891,7 +5904,7 @@ ReactFabricRenderer.injectIntoDevTools({
findFiberByHostInstance: getInstanceFromTag,
getInspectorDataForViewTag: getInspectorDataForViewTag,
bundleType: 0,
version: "16.3.0-alpha.1",
version: "16.3.0-alpha.2",
rendererPackageName: "react-native-renderer"
});
var ReactFabric$2 = Object.freeze({ default: ReactFabric }),

View File

@ -965,6 +965,7 @@ var Fragment = 10;
var Mode = 11;
var ContextConsumer = 12;
var ContextProvider = 13;
var ForwardRef = 14;
function getParent(inst) {
do {
@ -2802,6 +2803,9 @@ var REACT_CONTEXT_TYPE = hasSymbol ? Symbol["for"]("react.context") : 0xeace;
var REACT_ASYNC_MODE_TYPE = hasSymbol
? Symbol["for"]("react.async_mode")
: 0xeacf;
var REACT_FORWARD_REF_TYPE = hasSymbol
? Symbol["for"]("react.forward_ref")
: 0xead0;
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = "@@iterator";
@ -2983,7 +2987,7 @@ var TouchHistoryMath = {
// TODO: this is special because it gets imported during build.
var ReactVersion = "16.3.0-alpha.1";
var ReactVersion = "16.3.0-alpha.2";
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
@ -5500,6 +5504,9 @@ function createFiberFromElement(element, mode, expirationTime) {
// This is a consumer
fiberTag = ContextConsumer;
break;
case REACT_FORWARD_REF_TYPE:
fiberTag = ForwardRef;
break;
default:
if (typeof type.tag === "number") {
// Currently assumed to be a continuation and therefore is a
@ -7092,20 +7099,20 @@ var ReactFiberClassComponent = function(
// In order to support react-lifecycles-compat polyfilled components,
// Unsafe lifecycles should not be invoked for any component with the new gDSFP.
if (
(typeof instance.UNSAFE_componentWillUpdate === "function" ||
typeof instance.componentWillUpdate === "function") &&
(typeof instance.UNSAFE_componentWillMount === "function" ||
typeof instance.componentWillMount === "function") &&
typeof ctor.getDerivedStateFromProps !== "function"
) {
startPhaseTimer(workInProgress, "componentWillUpdate");
if (typeof instance.componentWillUpdate === "function") {
instance.componentWillUpdate(newProps, newState, newContext);
startPhaseTimer(workInProgress, "componentWillMount");
if (typeof instance.componentWillMount === "function") {
instance.componentWillMount();
}
if (typeof instance.UNSAFE_componentWillUpdate === "function") {
instance.UNSAFE_componentWillUpdate(newProps, newState, newContext);
if (typeof instance.UNSAFE_componentWillMount === "function") {
instance.UNSAFE_componentWillMount();
}
stopPhaseTimer();
}
if (typeof instance.componentDidUpdate === "function") {
if (typeof instance.componentDidMount === "function") {
workInProgress.effectTag |= Update;
}
} else {
@ -8725,6 +8732,14 @@ var ReactFiberBeginWork = function(
}
}
function updateForwardRef(current, workInProgress) {
var render = workInProgress.type.render;
var nextChildren = render(workInProgress.pendingProps, workInProgress.ref);
reconcileChildren(current, workInProgress, nextChildren);
memoizeProps(workInProgress, nextChildren);
return workInProgress.child;
}
function updateFragment(current, workInProgress) {
var nextChildren = workInProgress.pendingProps;
if (hasContextChanged()) {
@ -9678,6 +9693,8 @@ var ReactFiberBeginWork = function(
workInProgress,
renderExpirationTime
);
case ForwardRef:
return updateForwardRef(current, workInProgress);
case Fragment:
return updateFragment(current, workInProgress);
case Mode:
@ -10230,6 +10247,8 @@ var ReactFiberCompleteWork = function(config, hostContext, hydrationContext) {
case ReturnComponent:
// Does nothing.
return null;
case ForwardRef:
return null;
case Fragment:
return null;
case Mode:
@ -10569,7 +10588,7 @@ var ReactFiberCommitWork = function(
}
}
} else {
ref.value = null;
ref.current = null;
}
}
}
@ -10734,7 +10753,19 @@ var ReactFiberCommitWork = function(
if (typeof ref === "function") {
ref(instanceToUse);
} else {
ref.value = instanceToUse;
{
if (!ref.hasOwnProperty("current")) {
warning(
false,
"Unexpected ref object provided for %s. " +
"Use either a ref-setter function or Reacte.createRef().%s",
getComponentName(finishedWork),
getStackAddendumByWorkInProgressFiber(finishedWork)
);
}
}
ref.current = instanceToUse;
}
}
}
@ -10745,7 +10776,7 @@ var ReactFiberCommitWork = function(
if (typeof currentRef === "function") {
currentRef(null);
} else {
currentRef.value = null;
currentRef.current = null;
}
}
}

View File

@ -1174,6 +1174,9 @@ var hasSymbol = "function" === typeof Symbol && Symbol["for"],
REACT_PROVIDER_TYPE = hasSymbol ? Symbol["for"]("react.provider") : 60109,
REACT_CONTEXT_TYPE = hasSymbol ? Symbol["for"]("react.context") : 60110,
REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol["for"]("react.async_mode") : 60111,
REACT_FORWARD_REF_TYPE = hasSymbol
? Symbol["for"]("react.forward_ref")
: 60112,
MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator;
function getIteratorFn(maybeIterable) {
if (null === maybeIterable || "undefined" === typeof maybeIterable)
@ -2037,6 +2040,9 @@ function createFiberFromElement(element, mode, expirationTime) {
case REACT_CONTEXT_TYPE:
fiberTag = 12;
break;
case REACT_FORWARD_REF_TYPE:
fiberTag = 14;
break;
default:
if ("number" === typeof type.tag)
return (
@ -2551,22 +2557,14 @@ function ReactFiberClassComponent(
renderExpirationTime,
newUnmaskedContext
))
? (("function" !== typeof instance.UNSAFE_componentWillUpdate &&
"function" !== typeof instance.componentWillUpdate) ||
? (("function" !== typeof instance.UNSAFE_componentWillMount &&
"function" !== typeof instance.componentWillMount) ||
"function" === typeof ctor.getDerivedStateFromProps ||
("function" === typeof instance.componentWillUpdate &&
instance.componentWillUpdate(
newProps,
renderExpirationTime,
newUnmaskedContext
),
"function" === typeof instance.UNSAFE_componentWillUpdate &&
instance.UNSAFE_componentWillUpdate(
newProps,
renderExpirationTime,
newUnmaskedContext
)),
"function" === typeof instance.componentDidUpdate &&
("function" === typeof instance.componentWillMount &&
instance.componentWillMount(),
"function" === typeof instance.UNSAFE_componentWillMount &&
instance.UNSAFE_componentWillMount()),
"function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4))
: ("function" === typeof instance.componentDidMount &&
(workInProgress.effectTag |= 4),
@ -3932,6 +3930,17 @@ function ReactFiberBeginWork(
)),
current
);
case 14:
return (
(renderExpirationTime = workInProgress.type.render),
(renderExpirationTime = renderExpirationTime(
workInProgress.pendingProps,
workInProgress.ref
)),
reconcileChildren(current, workInProgress, renderExpirationTime),
(workInProgress.memoizedProps = renderExpirationTime),
workInProgress.child
);
case 10:
return (
(renderExpirationTime = workInProgress.pendingProps),
@ -4263,6 +4272,8 @@ function ReactFiberCompleteWork(config, hostContext, hydrationContext) {
return (workInProgress.tag = 7), null;
case 9:
return null;
case 14:
return null;
case 10:
return null;
case 11:
@ -4415,7 +4426,7 @@ function ReactFiberCommitWork(
} catch (refError) {
captureError(current, refError);
}
else ref.value = null;
else ref.current = null;
}
function commitUnmount(current) {
"function" === typeof onCommitUnmount && onCommitUnmount(current);
@ -4795,7 +4806,7 @@ function ReactFiberCommitWork(
}
"function" === typeof ref
? ref(finishedWork)
: (ref.value = finishedWork);
: (ref.current = finishedWork);
}
},
commitDetachRef: function(current) {
@ -4803,7 +4814,7 @@ function ReactFiberCommitWork(
null !== current &&
("function" === typeof current
? current(null)
: (current.value = null));
: (current.current = null));
}
};
}
@ -6352,7 +6363,7 @@ NativeRenderer.injectIntoDevTools({
findFiberByHostInstance: getInstanceFromTag,
getInspectorDataForViewTag: getInspectorDataForViewTag,
bundleType: 0,
version: "16.3.0-alpha.1",
version: "16.3.0-alpha.2",
rendererPackageName: "react-native-renderer"
});
var ReactNativeRenderer$2 = Object.freeze({ default: ReactNativeRenderer }),

View File

@ -101,5 +101,5 @@ export type ReactPortal = {
};
export type RefObject = {|
value: any,
current: any,
|};

View File

@ -142,7 +142,7 @@
"react-native": "local-cli/wrong-react-native.js"
},
"peerDependencies": {
"react": "^16.3.0-alpha.0"
"react": "^16.3.0-alpha.2"
},
"dependencies": {
"absolute-path": "^0.0.0",
@ -219,8 +219,8 @@
"jest": "22.4.2",
"jest-junit": "3.6.0",
"prettier": "1.9.1",
"react": "^16.3.0-alpha.1",
"react-test-renderer": "^16.3.0-alpha.1",
"react": "^16.3.0-alpha.2",
"react-test-renderer": "^16.3.0-alpha.2",
"shelljs": "^0.7.8",
"sinon": "^2.2.0"
}