mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Move ref type check to receiver (#28464)
The runtime contains a type check to determine if a user-provided ref is a valid type — a function or object (or a string, when `disableStringRefs` is off). This currently happens during child reconciliation. This changes it to happen only when the ref is passed to the component that the ref is being attached to. This is a continuation of the "ref as prop" change — until you actually pass a ref to a HostComponent, class, etc, ref is a normal prop that has no special behavior. DiffTrain build for commit https://github.com/facebook/react/commit/2f8f7760223241665f472a2a9be16650473bce39.
This commit is contained in:
+28
-30
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<c7f09b0ccfd717d023bd590c0cbfdace>>
|
||||
* @generated SignedSource<<514c453e36455da8cb22e0c8c9169c24>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -5067,18 +5067,17 @@ if (__DEV__) {
|
||||
element,
|
||||
mixedRef
|
||||
) {
|
||||
{
|
||||
checkPropStringCoercion(mixedRef, "ref");
|
||||
}
|
||||
|
||||
var stringRef = "" + mixedRef;
|
||||
var owner = element._owner;
|
||||
|
||||
if (!owner) {
|
||||
if (typeof mixedRef !== "string") {
|
||||
throw new Error(
|
||||
"Expected ref to be a function, a string, an object returned by React.createRef(), or null."
|
||||
);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Element ref was specified as a string (" +
|
||||
mixedRef +
|
||||
stringRef +
|
||||
") but no owner was set. This could happen for one of" +
|
||||
" the following reasons:\n" +
|
||||
"1. You may be adding a ref to a function component\n" +
|
||||
@@ -5095,15 +5094,8 @@ if (__DEV__) {
|
||||
"Learn more about using refs safely here: " +
|
||||
"https://reactjs.org/link/strict-mode-string-ref"
|
||||
);
|
||||
} // At this point, we know the ref isn't an object or function but it could
|
||||
// be a number. Coerce it to a string.
|
||||
|
||||
{
|
||||
checkPropStringCoercion(mixedRef, "ref");
|
||||
}
|
||||
|
||||
var stringRef = "" + mixedRef;
|
||||
|
||||
{
|
||||
if (
|
||||
// Will already warn with "Function components cannot be given refs"
|
||||
@@ -5175,12 +5167,10 @@ if (__DEV__) {
|
||||
var coercedRef;
|
||||
|
||||
if (
|
||||
mixedRef !== null &&
|
||||
typeof mixedRef !== "function" &&
|
||||
typeof mixedRef !== "object"
|
||||
typeof mixedRef === "string" ||
|
||||
typeof mixedRef === "number" ||
|
||||
typeof mixedRef === "boolean"
|
||||
) {
|
||||
// Assume this is a string ref. If it's not, then this will throw an error
|
||||
// to the user.
|
||||
coercedRef = convertStringRefToCallbackRef(
|
||||
returnFiber,
|
||||
current,
|
||||
@@ -13232,17 +13222,25 @@ if (__DEV__) {
|
||||
}
|
||||
|
||||
function markRef(current, workInProgress) {
|
||||
// TODO: This is also where we should check the type of the ref and error if
|
||||
// an invalid one is passed, instead of during child reconcilation.
|
||||
// TODO: Check props.ref instead of fiber.ref when enableRefAsProp is on.
|
||||
var ref = workInProgress.ref;
|
||||
|
||||
if (
|
||||
(current === null && ref !== null) ||
|
||||
(current !== null && current.ref !== ref)
|
||||
) {
|
||||
// Schedule a Ref effect
|
||||
workInProgress.flags |= Ref;
|
||||
workInProgress.flags |= RefStatic;
|
||||
if (ref === null) {
|
||||
if (current !== null && current.ref !== null) {
|
||||
// Schedule a Ref effect
|
||||
workInProgress.flags |= Ref | RefStatic;
|
||||
}
|
||||
} else {
|
||||
if (typeof ref !== "function" && typeof ref !== "object") {
|
||||
throw new Error(
|
||||
"Expected ref to be a function, an object returned by React.createRef(), or undefined/null."
|
||||
);
|
||||
}
|
||||
|
||||
if (current === null || current.ref !== ref) {
|
||||
// Schedule a Ref effect
|
||||
workInProgress.flags |= Ref | RefStatic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25735,7 +25733,7 @@ if (__DEV__) {
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-canary-bb4b147da-20240229";
|
||||
var ReactVersion = "18.3.0-canary-2f8f77602-20240229";
|
||||
|
||||
// Might add PROFILE later.
|
||||
|
||||
|
||||
+22
-20
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<74c9b737997575eb03bf09dfe096e458>>
|
||||
* @generated SignedSource<<c9fcc719668d07b3a623f14e395c32b8>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -1464,24 +1464,19 @@ function convertStringRefToCallbackRef(
|
||||
var refs = inst.refs;
|
||||
null === value ? delete refs[stringRef] : (refs[stringRef] = value);
|
||||
}
|
||||
var stringRef = "" + mixedRef;
|
||||
returnFiber = element._owner;
|
||||
if (!returnFiber) {
|
||||
if ("string" !== typeof mixedRef)
|
||||
throw Error(
|
||||
"Expected ref to be a function, a string, an object returned by React.createRef(), or null."
|
||||
);
|
||||
if (!returnFiber)
|
||||
throw Error(
|
||||
"Element ref was specified as a string (" +
|
||||
mixedRef +
|
||||
stringRef +
|
||||
") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information."
|
||||
);
|
||||
}
|
||||
if (1 !== returnFiber.tag)
|
||||
throw Error(
|
||||
"Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref"
|
||||
);
|
||||
var stringRef = "" + mixedRef,
|
||||
inst = returnFiber.stateNode;
|
||||
var inst = returnFiber.stateNode;
|
||||
if (!inst)
|
||||
throw Error(
|
||||
"Missing owner for string ref " +
|
||||
@@ -1501,9 +1496,9 @@ function convertStringRefToCallbackRef(
|
||||
function coerceRef(returnFiber, current, workInProgress, element) {
|
||||
var mixedRef = element.ref;
|
||||
returnFiber =
|
||||
null !== mixedRef &&
|
||||
"function" !== typeof mixedRef &&
|
||||
"object" !== typeof mixedRef
|
||||
"string" === typeof mixedRef ||
|
||||
"number" === typeof mixedRef ||
|
||||
"boolean" === typeof mixedRef
|
||||
? convertStringRefToCallbackRef(returnFiber, current, element, mixedRef)
|
||||
: mixedRef;
|
||||
workInProgress.ref = returnFiber;
|
||||
@@ -3986,11 +3981,18 @@ function deferHiddenOffscreenComponent(current, workInProgress, nextBaseLanes) {
|
||||
}
|
||||
function markRef(current, workInProgress) {
|
||||
var ref = workInProgress.ref;
|
||||
if (
|
||||
(null === current && null !== ref) ||
|
||||
(null !== current && current.ref !== ref)
|
||||
)
|
||||
(workInProgress.flags |= 512), (workInProgress.flags |= 2097152);
|
||||
if (null === ref)
|
||||
null !== current &&
|
||||
null !== current.ref &&
|
||||
(workInProgress.flags |= 2097664);
|
||||
else {
|
||||
if ("function" !== typeof ref && "object" !== typeof ref)
|
||||
throw Error(
|
||||
"Expected ref to be a function, an object returned by React.createRef(), or undefined/null."
|
||||
);
|
||||
if (null === current || current.ref !== ref)
|
||||
workInProgress.flags |= 2097664;
|
||||
}
|
||||
}
|
||||
function updateFunctionComponent(
|
||||
current,
|
||||
@@ -9171,7 +9173,7 @@ var devToolsConfig$jscomp$inline_1014 = {
|
||||
throw Error("TestRenderer does not support findFiberByHostInstance()");
|
||||
},
|
||||
bundleType: 0,
|
||||
version: "18.3.0-canary-bb4b147da-20240229",
|
||||
version: "18.3.0-canary-2f8f77602-20240229",
|
||||
rendererPackageName: "react-test-renderer"
|
||||
};
|
||||
var internals$jscomp$inline_1195 = {
|
||||
@@ -9202,7 +9204,7 @@ var internals$jscomp$inline_1195 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-canary-bb4b147da-20240229"
|
||||
reconcilerVersion: "18.3.0-canary-2f8f77602-20240229"
|
||||
};
|
||||
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
var hook$jscomp$inline_1196 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
|
||||
+22
-20
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<86e7f77200b19412957b194553a75177>>
|
||||
* @generated SignedSource<<749ebcbb693ef8635dc1c79f3b3a628d>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -1484,24 +1484,19 @@ function convertStringRefToCallbackRef(
|
||||
var refs = inst.refs;
|
||||
null === value ? delete refs[stringRef] : (refs[stringRef] = value);
|
||||
}
|
||||
var stringRef = "" + mixedRef;
|
||||
returnFiber = element._owner;
|
||||
if (!returnFiber) {
|
||||
if ("string" !== typeof mixedRef)
|
||||
throw Error(
|
||||
"Expected ref to be a function, a string, an object returned by React.createRef(), or null."
|
||||
);
|
||||
if (!returnFiber)
|
||||
throw Error(
|
||||
"Element ref was specified as a string (" +
|
||||
mixedRef +
|
||||
stringRef +
|
||||
") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information."
|
||||
);
|
||||
}
|
||||
if (1 !== returnFiber.tag)
|
||||
throw Error(
|
||||
"Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref"
|
||||
);
|
||||
var stringRef = "" + mixedRef,
|
||||
inst = returnFiber.stateNode;
|
||||
var inst = returnFiber.stateNode;
|
||||
if (!inst)
|
||||
throw Error(
|
||||
"Missing owner for string ref " +
|
||||
@@ -1521,9 +1516,9 @@ function convertStringRefToCallbackRef(
|
||||
function coerceRef(returnFiber, current, workInProgress, element) {
|
||||
var mixedRef = element.ref;
|
||||
returnFiber =
|
||||
null !== mixedRef &&
|
||||
"function" !== typeof mixedRef &&
|
||||
"object" !== typeof mixedRef
|
||||
"string" === typeof mixedRef ||
|
||||
"number" === typeof mixedRef ||
|
||||
"boolean" === typeof mixedRef
|
||||
? convertStringRefToCallbackRef(returnFiber, current, element, mixedRef)
|
||||
: mixedRef;
|
||||
workInProgress.ref = returnFiber;
|
||||
@@ -4068,11 +4063,18 @@ function deferHiddenOffscreenComponent(current, workInProgress, nextBaseLanes) {
|
||||
}
|
||||
function markRef(current, workInProgress) {
|
||||
var ref = workInProgress.ref;
|
||||
if (
|
||||
(null === current && null !== ref) ||
|
||||
(null !== current && current.ref !== ref)
|
||||
)
|
||||
(workInProgress.flags |= 512), (workInProgress.flags |= 2097152);
|
||||
if (null === ref)
|
||||
null !== current &&
|
||||
null !== current.ref &&
|
||||
(workInProgress.flags |= 2097664);
|
||||
else {
|
||||
if ("function" !== typeof ref && "object" !== typeof ref)
|
||||
throw Error(
|
||||
"Expected ref to be a function, an object returned by React.createRef(), or undefined/null."
|
||||
);
|
||||
if (null === current || current.ref !== ref)
|
||||
workInProgress.flags |= 2097664;
|
||||
}
|
||||
}
|
||||
function updateFunctionComponent(
|
||||
current,
|
||||
@@ -9599,7 +9601,7 @@ var devToolsConfig$jscomp$inline_1056 = {
|
||||
throw Error("TestRenderer does not support findFiberByHostInstance()");
|
||||
},
|
||||
bundleType: 0,
|
||||
version: "18.3.0-canary-bb4b147da-20240229",
|
||||
version: "18.3.0-canary-2f8f77602-20240229",
|
||||
rendererPackageName: "react-test-renderer"
|
||||
};
|
||||
var internals$jscomp$inline_1236 = {
|
||||
@@ -9630,7 +9632,7 @@ var internals$jscomp$inline_1236 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-canary-bb4b147da-20240229"
|
||||
reconcilerVersion: "18.3.0-canary-2f8f77602-20240229"
|
||||
};
|
||||
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
var hook$jscomp$inline_1237 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ if (__DEV__) {
|
||||
}
|
||||
var dynamicFlags = require("ReactNativeInternalFeatureFlags");
|
||||
|
||||
var ReactVersion = "18.3.0-canary-bb4b147da-20240229";
|
||||
var ReactVersion = "18.3.0-canary-2f8f77602-20240229";
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
|
||||
+1
-1
@@ -598,4 +598,4 @@ exports.useSyncExternalStore = function (
|
||||
exports.useTransition = function () {
|
||||
return ReactCurrentDispatcher.current.useTransition();
|
||||
};
|
||||
exports.version = "18.3.0-canary-bb4b147da-20240229";
|
||||
exports.version = "18.3.0-canary-2f8f77602-20240229";
|
||||
|
||||
+1
-1
@@ -594,7 +594,7 @@ exports.useSyncExternalStore = function (
|
||||
exports.useTransition = function () {
|
||||
return ReactCurrentDispatcher.current.useTransition();
|
||||
};
|
||||
exports.version = "18.3.0-canary-bb4b147da-20240229";
|
||||
exports.version = "18.3.0-canary-2f8f77602-20240229";
|
||||
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
||||
"function" ===
|
||||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
bb4b147da9a892529995f55f15f19f46a00cf4f6
|
||||
2f8f7760223241665f472a2a9be16650473bce39
|
||||
|
||||
+28
-30
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<a30628fd998018c262d2437b0c9edc0e>>
|
||||
* @generated SignedSource<<409fcb610c96c788e5d00c80fb0cad50>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -8976,18 +8976,17 @@ to return true:wantsResponderID| |
|
||||
element,
|
||||
mixedRef
|
||||
) {
|
||||
{
|
||||
checkPropStringCoercion(mixedRef, "ref");
|
||||
}
|
||||
|
||||
var stringRef = "" + mixedRef;
|
||||
var owner = element._owner;
|
||||
|
||||
if (!owner) {
|
||||
if (typeof mixedRef !== "string") {
|
||||
throw new Error(
|
||||
"Expected ref to be a function, a string, an object returned by React.createRef(), or null."
|
||||
);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Element ref was specified as a string (" +
|
||||
mixedRef +
|
||||
stringRef +
|
||||
") but no owner was set. This could happen for one of" +
|
||||
" the following reasons:\n" +
|
||||
"1. You may be adding a ref to a function component\n" +
|
||||
@@ -9004,15 +9003,8 @@ to return true:wantsResponderID| |
|
||||
"Learn more about using refs safely here: " +
|
||||
"https://reactjs.org/link/strict-mode-string-ref"
|
||||
);
|
||||
} // At this point, we know the ref isn't an object or function but it could
|
||||
// be a number. Coerce it to a string.
|
||||
|
||||
{
|
||||
checkPropStringCoercion(mixedRef, "ref");
|
||||
}
|
||||
|
||||
var stringRef = "" + mixedRef;
|
||||
|
||||
{
|
||||
if (
|
||||
// Will already warn with "Function components cannot be given refs"
|
||||
@@ -9084,12 +9076,10 @@ to return true:wantsResponderID| |
|
||||
var coercedRef;
|
||||
|
||||
if (
|
||||
mixedRef !== null &&
|
||||
typeof mixedRef !== "function" &&
|
||||
typeof mixedRef !== "object"
|
||||
typeof mixedRef === "string" ||
|
||||
typeof mixedRef === "number" ||
|
||||
typeof mixedRef === "boolean"
|
||||
) {
|
||||
// Assume this is a string ref. If it's not, then this will throw an error
|
||||
// to the user.
|
||||
coercedRef = convertStringRefToCallbackRef(
|
||||
returnFiber,
|
||||
current,
|
||||
@@ -16418,17 +16408,25 @@ to return true:wantsResponderID| |
|
||||
}
|
||||
|
||||
function markRef(current, workInProgress) {
|
||||
// TODO: This is also where we should check the type of the ref and error if
|
||||
// an invalid one is passed, instead of during child reconcilation.
|
||||
// TODO: Check props.ref instead of fiber.ref when enableRefAsProp is on.
|
||||
var ref = workInProgress.ref;
|
||||
|
||||
if (
|
||||
(current === null && ref !== null) ||
|
||||
(current !== null && current.ref !== ref)
|
||||
) {
|
||||
// Schedule a Ref effect
|
||||
workInProgress.flags |= Ref;
|
||||
workInProgress.flags |= RefStatic;
|
||||
if (ref === null) {
|
||||
if (current !== null && current.ref !== null) {
|
||||
// Schedule a Ref effect
|
||||
workInProgress.flags |= Ref | RefStatic;
|
||||
}
|
||||
} else {
|
||||
if (typeof ref !== "function" && typeof ref !== "object") {
|
||||
throw new Error(
|
||||
"Expected ref to be a function, an object returned by React.createRef(), or undefined/null."
|
||||
);
|
||||
}
|
||||
|
||||
if (current === null || current.ref !== ref) {
|
||||
// Schedule a Ref effect
|
||||
workInProgress.flags |= Ref | RefStatic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28090,7 +28088,7 @@ to return true:wantsResponderID| |
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-canary-b1191c0d";
|
||||
var ReactVersion = "18.3.0-canary-79e0cf8d";
|
||||
|
||||
function createPortal$1(
|
||||
children,
|
||||
|
||||
+22
-20
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<e493b8167ced7ca3ebf077729b6710c3>>
|
||||
* @generated SignedSource<<554f53e63c9c8753adcd614a35749b60>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -2891,24 +2891,19 @@ function convertStringRefToCallbackRef(
|
||||
var refs = inst.refs;
|
||||
null === value ? delete refs[stringRef] : (refs[stringRef] = value);
|
||||
}
|
||||
var stringRef = "" + mixedRef;
|
||||
returnFiber = element._owner;
|
||||
if (!returnFiber) {
|
||||
if ("string" !== typeof mixedRef)
|
||||
throw Error(
|
||||
"Expected ref to be a function, a string, an object returned by React.createRef(), or null."
|
||||
);
|
||||
if (!returnFiber)
|
||||
throw Error(
|
||||
"Element ref was specified as a string (" +
|
||||
mixedRef +
|
||||
stringRef +
|
||||
") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information."
|
||||
);
|
||||
}
|
||||
if (1 !== returnFiber.tag)
|
||||
throw Error(
|
||||
"Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref"
|
||||
);
|
||||
var stringRef = "" + mixedRef,
|
||||
inst = returnFiber.stateNode;
|
||||
var inst = returnFiber.stateNode;
|
||||
if (!inst)
|
||||
throw Error(
|
||||
"Missing owner for string ref " +
|
||||
@@ -2928,9 +2923,9 @@ function convertStringRefToCallbackRef(
|
||||
function coerceRef(returnFiber, current, workInProgress, element) {
|
||||
var mixedRef = element.ref;
|
||||
returnFiber =
|
||||
null !== mixedRef &&
|
||||
"function" !== typeof mixedRef &&
|
||||
"object" !== typeof mixedRef
|
||||
"string" === typeof mixedRef ||
|
||||
"number" === typeof mixedRef ||
|
||||
"boolean" === typeof mixedRef
|
||||
? convertStringRefToCallbackRef(returnFiber, current, element, mixedRef)
|
||||
: mixedRef;
|
||||
workInProgress.ref = returnFiber;
|
||||
@@ -5123,11 +5118,18 @@ function deferHiddenOffscreenComponent(current, workInProgress, nextBaseLanes) {
|
||||
}
|
||||
function markRef(current, workInProgress) {
|
||||
var ref = workInProgress.ref;
|
||||
if (
|
||||
(null === current && null !== ref) ||
|
||||
(null !== current && current.ref !== ref)
|
||||
)
|
||||
(workInProgress.flags |= 512), (workInProgress.flags |= 2097152);
|
||||
if (null === ref)
|
||||
null !== current &&
|
||||
null !== current.ref &&
|
||||
(workInProgress.flags |= 2097664);
|
||||
else {
|
||||
if ("function" !== typeof ref && "object" !== typeof ref)
|
||||
throw Error(
|
||||
"Expected ref to be a function, an object returned by React.createRef(), or undefined/null."
|
||||
);
|
||||
if (null === current || current.ref !== ref)
|
||||
workInProgress.flags |= 2097664;
|
||||
}
|
||||
}
|
||||
function updateFunctionComponent(
|
||||
current,
|
||||
@@ -9705,7 +9707,7 @@ var roots = new Map(),
|
||||
devToolsConfig$jscomp$inline_1059 = {
|
||||
findFiberByHostInstance: getInstanceFromNode,
|
||||
bundleType: 0,
|
||||
version: "18.3.0-canary-2f67afac",
|
||||
version: "18.3.0-canary-241dc610",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
rendererConfig: {
|
||||
getInspectorDataForInstance: getInspectorDataForInstance,
|
||||
@@ -9748,7 +9750,7 @@ var internals$jscomp$inline_1284 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-canary-2f67afac"
|
||||
reconcilerVersion: "18.3.0-canary-241dc610"
|
||||
};
|
||||
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
var hook$jscomp$inline_1285 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
|
||||
+22
-20
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<225029855a5d7573ff10fa1f1445bcaf>>
|
||||
* @generated SignedSource<<22c727d3b43debc1d3b0419f1de92333>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -3016,24 +3016,19 @@ function convertStringRefToCallbackRef(
|
||||
var refs = inst.refs;
|
||||
null === value ? delete refs[stringRef] : (refs[stringRef] = value);
|
||||
}
|
||||
var stringRef = "" + mixedRef;
|
||||
returnFiber = element._owner;
|
||||
if (!returnFiber) {
|
||||
if ("string" !== typeof mixedRef)
|
||||
throw Error(
|
||||
"Expected ref to be a function, a string, an object returned by React.createRef(), or null."
|
||||
);
|
||||
if (!returnFiber)
|
||||
throw Error(
|
||||
"Element ref was specified as a string (" +
|
||||
mixedRef +
|
||||
stringRef +
|
||||
") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information."
|
||||
);
|
||||
}
|
||||
if (1 !== returnFiber.tag)
|
||||
throw Error(
|
||||
"Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref"
|
||||
);
|
||||
var stringRef = "" + mixedRef,
|
||||
inst = returnFiber.stateNode;
|
||||
var inst = returnFiber.stateNode;
|
||||
if (!inst)
|
||||
throw Error(
|
||||
"Missing owner for string ref " +
|
||||
@@ -3053,9 +3048,9 @@ function convertStringRefToCallbackRef(
|
||||
function coerceRef(returnFiber, current, workInProgress, element) {
|
||||
var mixedRef = element.ref;
|
||||
returnFiber =
|
||||
null !== mixedRef &&
|
||||
"function" !== typeof mixedRef &&
|
||||
"object" !== typeof mixedRef
|
||||
"string" === typeof mixedRef ||
|
||||
"number" === typeof mixedRef ||
|
||||
"boolean" === typeof mixedRef
|
||||
? convertStringRefToCallbackRef(returnFiber, current, element, mixedRef)
|
||||
: mixedRef;
|
||||
workInProgress.ref = returnFiber;
|
||||
@@ -5320,11 +5315,18 @@ function deferHiddenOffscreenComponent(current, workInProgress, nextBaseLanes) {
|
||||
}
|
||||
function markRef(current, workInProgress) {
|
||||
var ref = workInProgress.ref;
|
||||
if (
|
||||
(null === current && null !== ref) ||
|
||||
(null !== current && current.ref !== ref)
|
||||
)
|
||||
(workInProgress.flags |= 512), (workInProgress.flags |= 2097152);
|
||||
if (null === ref)
|
||||
null !== current &&
|
||||
null !== current.ref &&
|
||||
(workInProgress.flags |= 2097664);
|
||||
else {
|
||||
if ("function" !== typeof ref && "object" !== typeof ref)
|
||||
throw Error(
|
||||
"Expected ref to be a function, an object returned by React.createRef(), or undefined/null."
|
||||
);
|
||||
if (null === current || current.ref !== ref)
|
||||
workInProgress.flags |= 2097664;
|
||||
}
|
||||
}
|
||||
function updateFunctionComponent(
|
||||
current,
|
||||
@@ -10407,7 +10409,7 @@ var roots = new Map(),
|
||||
devToolsConfig$jscomp$inline_1137 = {
|
||||
findFiberByHostInstance: getInstanceFromNode,
|
||||
bundleType: 0,
|
||||
version: "18.3.0-canary-22c30fbb",
|
||||
version: "18.3.0-canary-3d21d46a",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
rendererConfig: {
|
||||
getInspectorDataForInstance: getInspectorDataForInstance,
|
||||
@@ -10463,7 +10465,7 @@ var roots = new Map(),
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-canary-22c30fbb"
|
||||
reconcilerVersion: "18.3.0-canary-3d21d46a"
|
||||
});
|
||||
exports.createPortal = function (children, containerTag) {
|
||||
return createPortal$1(
|
||||
|
||||
+28
-30
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<a48d094a5da1ea0ce8f52cc892ead47c>>
|
||||
* @generated SignedSource<<8115bda793528a085e7459e0166827d3>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -9247,18 +9247,17 @@ to return true:wantsResponderID| |
|
||||
element,
|
||||
mixedRef
|
||||
) {
|
||||
{
|
||||
checkPropStringCoercion(mixedRef, "ref");
|
||||
}
|
||||
|
||||
var stringRef = "" + mixedRef;
|
||||
var owner = element._owner;
|
||||
|
||||
if (!owner) {
|
||||
if (typeof mixedRef !== "string") {
|
||||
throw new Error(
|
||||
"Expected ref to be a function, a string, an object returned by React.createRef(), or null."
|
||||
);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Element ref was specified as a string (" +
|
||||
mixedRef +
|
||||
stringRef +
|
||||
") but no owner was set. This could happen for one of" +
|
||||
" the following reasons:\n" +
|
||||
"1. You may be adding a ref to a function component\n" +
|
||||
@@ -9275,15 +9274,8 @@ to return true:wantsResponderID| |
|
||||
"Learn more about using refs safely here: " +
|
||||
"https://reactjs.org/link/strict-mode-string-ref"
|
||||
);
|
||||
} // At this point, we know the ref isn't an object or function but it could
|
||||
// be a number. Coerce it to a string.
|
||||
|
||||
{
|
||||
checkPropStringCoercion(mixedRef, "ref");
|
||||
}
|
||||
|
||||
var stringRef = "" + mixedRef;
|
||||
|
||||
{
|
||||
if (
|
||||
// Will already warn with "Function components cannot be given refs"
|
||||
@@ -9355,12 +9347,10 @@ to return true:wantsResponderID| |
|
||||
var coercedRef;
|
||||
|
||||
if (
|
||||
mixedRef !== null &&
|
||||
typeof mixedRef !== "function" &&
|
||||
typeof mixedRef !== "object"
|
||||
typeof mixedRef === "string" ||
|
||||
typeof mixedRef === "number" ||
|
||||
typeof mixedRef === "boolean"
|
||||
) {
|
||||
// Assume this is a string ref. If it's not, then this will throw an error
|
||||
// to the user.
|
||||
coercedRef = convertStringRefToCallbackRef(
|
||||
returnFiber,
|
||||
current,
|
||||
@@ -16689,17 +16679,25 @@ to return true:wantsResponderID| |
|
||||
}
|
||||
|
||||
function markRef(current, workInProgress) {
|
||||
// TODO: This is also where we should check the type of the ref and error if
|
||||
// an invalid one is passed, instead of during child reconcilation.
|
||||
// TODO: Check props.ref instead of fiber.ref when enableRefAsProp is on.
|
||||
var ref = workInProgress.ref;
|
||||
|
||||
if (
|
||||
(current === null && ref !== null) ||
|
||||
(current !== null && current.ref !== ref)
|
||||
) {
|
||||
// Schedule a Ref effect
|
||||
workInProgress.flags |= Ref;
|
||||
workInProgress.flags |= RefStatic;
|
||||
if (ref === null) {
|
||||
if (current !== null && current.ref !== null) {
|
||||
// Schedule a Ref effect
|
||||
workInProgress.flags |= Ref | RefStatic;
|
||||
}
|
||||
} else {
|
||||
if (typeof ref !== "function" && typeof ref !== "object") {
|
||||
throw new Error(
|
||||
"Expected ref to be a function, an object returned by React.createRef(), or undefined/null."
|
||||
);
|
||||
}
|
||||
|
||||
if (current === null || current.ref !== ref) {
|
||||
// Schedule a Ref effect
|
||||
workInProgress.flags |= Ref | RefStatic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28530,7 +28528,7 @@ to return true:wantsResponderID| |
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-canary-58d268df";
|
||||
var ReactVersion = "18.3.0-canary-951ec3ac";
|
||||
|
||||
function createPortal$1(
|
||||
children,
|
||||
|
||||
+22
-20
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<bb4b9808e321e6022f7fa190090c451f>>
|
||||
* @generated SignedSource<<5851ed8034e7e6767df6c7658646bfa3>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -2956,24 +2956,19 @@ function convertStringRefToCallbackRef(
|
||||
var refs = inst.refs;
|
||||
null === value ? delete refs[stringRef] : (refs[stringRef] = value);
|
||||
}
|
||||
var stringRef = "" + mixedRef;
|
||||
returnFiber = element._owner;
|
||||
if (!returnFiber) {
|
||||
if ("string" !== typeof mixedRef)
|
||||
throw Error(
|
||||
"Expected ref to be a function, a string, an object returned by React.createRef(), or null."
|
||||
);
|
||||
if (!returnFiber)
|
||||
throw Error(
|
||||
"Element ref was specified as a string (" +
|
||||
mixedRef +
|
||||
stringRef +
|
||||
") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information."
|
||||
);
|
||||
}
|
||||
if (1 !== returnFiber.tag)
|
||||
throw Error(
|
||||
"Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref"
|
||||
);
|
||||
var stringRef = "" + mixedRef,
|
||||
inst = returnFiber.stateNode;
|
||||
var inst = returnFiber.stateNode;
|
||||
if (!inst)
|
||||
throw Error(
|
||||
"Missing owner for string ref " +
|
||||
@@ -2993,9 +2988,9 @@ function convertStringRefToCallbackRef(
|
||||
function coerceRef(returnFiber, current, workInProgress, element) {
|
||||
var mixedRef = element.ref;
|
||||
returnFiber =
|
||||
null !== mixedRef &&
|
||||
"function" !== typeof mixedRef &&
|
||||
"object" !== typeof mixedRef
|
||||
"string" === typeof mixedRef ||
|
||||
"number" === typeof mixedRef ||
|
||||
"boolean" === typeof mixedRef
|
||||
? convertStringRefToCallbackRef(returnFiber, current, element, mixedRef)
|
||||
: mixedRef;
|
||||
workInProgress.ref = returnFiber;
|
||||
@@ -5188,11 +5183,18 @@ function deferHiddenOffscreenComponent(current, workInProgress, nextBaseLanes) {
|
||||
}
|
||||
function markRef(current, workInProgress) {
|
||||
var ref = workInProgress.ref;
|
||||
if (
|
||||
(null === current && null !== ref) ||
|
||||
(null !== current && current.ref !== ref)
|
||||
)
|
||||
(workInProgress.flags |= 512), (workInProgress.flags |= 2097152);
|
||||
if (null === ref)
|
||||
null !== current &&
|
||||
null !== current.ref &&
|
||||
(workInProgress.flags |= 2097664);
|
||||
else {
|
||||
if ("function" !== typeof ref && "object" !== typeof ref)
|
||||
throw Error(
|
||||
"Expected ref to be a function, an object returned by React.createRef(), or undefined/null."
|
||||
);
|
||||
if (null === current || current.ref !== ref)
|
||||
workInProgress.flags |= 2097664;
|
||||
}
|
||||
}
|
||||
function updateFunctionComponent(
|
||||
current,
|
||||
@@ -9923,7 +9925,7 @@ var roots = new Map(),
|
||||
devToolsConfig$jscomp$inline_1128 = {
|
||||
findFiberByHostInstance: getInstanceFromTag,
|
||||
bundleType: 0,
|
||||
version: "18.3.0-canary-bdd9cd5c",
|
||||
version: "18.3.0-canary-06f130e8",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
rendererConfig: {
|
||||
getInspectorDataForInstance: getInspectorDataForInstance,
|
||||
@@ -9966,7 +9968,7 @@ var internals$jscomp$inline_1367 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-canary-bdd9cd5c"
|
||||
reconcilerVersion: "18.3.0-canary-06f130e8"
|
||||
};
|
||||
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
var hook$jscomp$inline_1368 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
|
||||
+22
-20
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<b6dafee497bc067606d199ce482f92ee>>
|
||||
* @generated SignedSource<<2ac537308632647a4cb69db0af181ea0>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -3080,24 +3080,19 @@ function convertStringRefToCallbackRef(
|
||||
var refs = inst.refs;
|
||||
null === value ? delete refs[stringRef] : (refs[stringRef] = value);
|
||||
}
|
||||
var stringRef = "" + mixedRef;
|
||||
returnFiber = element._owner;
|
||||
if (!returnFiber) {
|
||||
if ("string" !== typeof mixedRef)
|
||||
throw Error(
|
||||
"Expected ref to be a function, a string, an object returned by React.createRef(), or null."
|
||||
);
|
||||
if (!returnFiber)
|
||||
throw Error(
|
||||
"Element ref was specified as a string (" +
|
||||
mixedRef +
|
||||
stringRef +
|
||||
") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information."
|
||||
);
|
||||
}
|
||||
if (1 !== returnFiber.tag)
|
||||
throw Error(
|
||||
"Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref"
|
||||
);
|
||||
var stringRef = "" + mixedRef,
|
||||
inst = returnFiber.stateNode;
|
||||
var inst = returnFiber.stateNode;
|
||||
if (!inst)
|
||||
throw Error(
|
||||
"Missing owner for string ref " +
|
||||
@@ -3117,9 +3112,9 @@ function convertStringRefToCallbackRef(
|
||||
function coerceRef(returnFiber, current, workInProgress, element) {
|
||||
var mixedRef = element.ref;
|
||||
returnFiber =
|
||||
null !== mixedRef &&
|
||||
"function" !== typeof mixedRef &&
|
||||
"object" !== typeof mixedRef
|
||||
"string" === typeof mixedRef ||
|
||||
"number" === typeof mixedRef ||
|
||||
"boolean" === typeof mixedRef
|
||||
? convertStringRefToCallbackRef(returnFiber, current, element, mixedRef)
|
||||
: mixedRef;
|
||||
workInProgress.ref = returnFiber;
|
||||
@@ -5384,11 +5379,18 @@ function deferHiddenOffscreenComponent(current, workInProgress, nextBaseLanes) {
|
||||
}
|
||||
function markRef(current, workInProgress) {
|
||||
var ref = workInProgress.ref;
|
||||
if (
|
||||
(null === current && null !== ref) ||
|
||||
(null !== current && current.ref !== ref)
|
||||
)
|
||||
(workInProgress.flags |= 512), (workInProgress.flags |= 2097152);
|
||||
if (null === ref)
|
||||
null !== current &&
|
||||
null !== current.ref &&
|
||||
(workInProgress.flags |= 2097664);
|
||||
else {
|
||||
if ("function" !== typeof ref && "object" !== typeof ref)
|
||||
throw Error(
|
||||
"Expected ref to be a function, an object returned by React.createRef(), or undefined/null."
|
||||
);
|
||||
if (null === current || current.ref !== ref)
|
||||
workInProgress.flags |= 2097664;
|
||||
}
|
||||
}
|
||||
function updateFunctionComponent(
|
||||
current,
|
||||
@@ -10625,7 +10627,7 @@ var roots = new Map(),
|
||||
devToolsConfig$jscomp$inline_1206 = {
|
||||
findFiberByHostInstance: getInstanceFromTag,
|
||||
bundleType: 0,
|
||||
version: "18.3.0-canary-f7ec4633",
|
||||
version: "18.3.0-canary-bd69fbf0",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
rendererConfig: {
|
||||
getInspectorDataForInstance: getInspectorDataForInstance,
|
||||
@@ -10681,7 +10683,7 @@ var roots = new Map(),
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-canary-f7ec4633"
|
||||
reconcilerVersion: "18.3.0-canary-bd69fbf0"
|
||||
});
|
||||
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
|
||||
computeComponentStackForErrorReporting: function (reactTag) {
|
||||
|
||||
Reference in New Issue
Block a user