Skip to content

Commit caf4532

Browse files
committed
Use getComponentNameFromType for debug info for the key warning (#27930)
If this is a client reference we shouldn't dot into it, which would throw in the proxy. Interestingly our client references don't really have a `name` associated with them for debug information so a component type doesn't show up in error logs even though it seems like it should. DiffTrain build for commit 0ac3ea4.
1 parent 2a6d5ac commit caf4532

15 files changed

Lines changed: 165 additions & 111 deletions

File tree

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b85e6b4f686f35ddcd77f85e17cfc9f9>>
10+
* @generated SignedSource<<fc408c74cd117076cbc05c2d9747b81d>>
1111
*/
1212

1313
"use strict";
@@ -238,24 +238,22 @@ if (__DEV__) {
238238

239239
function getContextName$1(type) {
240240
return type.displayName || "Context";
241-
} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
241+
}
242+
243+
var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"); // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
242244

243245
function getComponentNameFromType(type) {
244246
if (type == null) {
245247
// Host root, text node or just invalid type.
246248
return null;
247249
}
248250

249-
{
250-
if (typeof type.tag === "number") {
251-
error(
252-
"Received an unexpected object in getComponentNameFromType(). " +
253-
"This is likely a bug in React. Please file an issue."
254-
);
251+
if (typeof type === "function") {
252+
if (type.$$typeof === REACT_CLIENT_REFERENCE) {
253+
// TODO: Create a convention for naming client references with debug info.
254+
return null;
255255
}
256-
}
257256

258-
if (typeof type === "function") {
259257
return type.displayName || type.name || null;
260258
}
261259

@@ -288,6 +286,15 @@ if (__DEV__) {
288286
}
289287

290288
if (typeof type === "object") {
289+
{
290+
if (typeof type.tag === "number") {
291+
error(
292+
"Received an unexpected object in getComponentNameFromType(). " +
293+
"This is likely a bug in React. Please file an issue."
294+
);
295+
}
296+
}
297+
291298
switch (type.$$typeof) {
292299
case REACT_CONTEXT_TYPE:
293300
var context = type;
@@ -25524,7 +25531,7 @@ if (__DEV__) {
2552425531
return root;
2552525532
}
2552625533

25527-
var ReactVersion = "18.3.0-canary-6639ed3b3-20240111";
25534+
var ReactVersion = "18.3.0-canary-0ac3ea471-20240111";
2552825535

2552925536
// Might add PROFILE later.
2553025537

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<98d1b8b04c6fa3a6d1a3f5d4d992bfdb>>
10+
* @generated SignedSource<<09dbf4f778ca917e96108791bdd4cd8e>>
1111
*/
1212

1313
"use strict";
@@ -59,9 +59,13 @@ function getIteratorFn(maybeIterable) {
5959
maybeIterable["@@iterator"];
6060
return "function" === typeof maybeIterable ? maybeIterable : null;
6161
}
62+
var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
6263
function getComponentNameFromType(type) {
6364
if (null == type) return null;
64-
if ("function" === typeof type) return type.displayName || type.name || null;
65+
if ("function" === typeof type)
66+
return type.$$typeof === REACT_CLIENT_REFERENCE
67+
? null
68+
: type.displayName || type.name || null;
6569
if ("string" === typeof type) return type;
6670
switch (type) {
6771
case REACT_FRAGMENT_TYPE:
@@ -9117,7 +9121,7 @@ var devToolsConfig$jscomp$inline_1037 = {
91179121
throw Error("TestRenderer does not support findFiberByHostInstance()");
91189122
},
91199123
bundleType: 0,
9120-
version: "18.3.0-canary-6639ed3b3-20240111",
9124+
version: "18.3.0-canary-0ac3ea471-20240111",
91219125
rendererPackageName: "react-test-renderer"
91229126
};
91239127
var internals$jscomp$inline_1230 = {
@@ -9148,7 +9152,7 @@ var internals$jscomp$inline_1230 = {
91489152
scheduleRoot: null,
91499153
setRefreshHandler: null,
91509154
getCurrentFiber: null,
9151-
reconcilerVersion: "18.3.0-canary-6639ed3b3-20240111"
9155+
reconcilerVersion: "18.3.0-canary-0ac3ea471-20240111"
91529156
};
91539157
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
91549158
var hook$jscomp$inline_1231 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<c3bf0acffb0597ee7ab235b17135524e>>
10+
* @generated SignedSource<<7b9b447b7ed58bc7f344d3fd301db92f>>
1111
*/
1212

1313
"use strict";
@@ -59,9 +59,13 @@ function getIteratorFn(maybeIterable) {
5959
maybeIterable["@@iterator"];
6060
return "function" === typeof maybeIterable ? maybeIterable : null;
6161
}
62+
var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
6263
function getComponentNameFromType(type) {
6364
if (null == type) return null;
64-
if ("function" === typeof type) return type.displayName || type.name || null;
65+
if ("function" === typeof type)
66+
return type.$$typeof === REACT_CLIENT_REFERENCE
67+
? null
68+
: type.displayName || type.name || null;
6569
if ("string" === typeof type) return type;
6670
switch (type) {
6771
case REACT_FRAGMENT_TYPE:
@@ -9545,7 +9549,7 @@ var devToolsConfig$jscomp$inline_1079 = {
95459549
throw Error("TestRenderer does not support findFiberByHostInstance()");
95469550
},
95479551
bundleType: 0,
9548-
version: "18.3.0-canary-6639ed3b3-20240111",
9552+
version: "18.3.0-canary-0ac3ea471-20240111",
95499553
rendererPackageName: "react-test-renderer"
95509554
};
95519555
var internals$jscomp$inline_1271 = {
@@ -9576,7 +9580,7 @@ var internals$jscomp$inline_1271 = {
95769580
scheduleRoot: null,
95779581
setRefreshHandler: null,
95789582
getCurrentFiber: null,
9579-
reconcilerVersion: "18.3.0-canary-6639ed3b3-20240111"
9583+
reconcilerVersion: "18.3.0-canary-0ac3ea471-20240111"
95809584
};
95819585
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
95829586
var hook$jscomp$inline_1272 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<8170be8fec46751a1d737fb773d9ff2c>>
10+
* @generated SignedSource<<3b95e8aa7ce2e31fd615f920b4402e91>>
1111
*/
1212

1313
"use strict";
@@ -106,7 +106,7 @@ if (__DEV__) {
106106
var enableScopeAPI = false;
107107
var enableTransitionTracing = false;
108108

109-
var REACT_CLIENT_REFERENCE$1 = Symbol.for("react.client.reference");
109+
var REACT_CLIENT_REFERENCE$2 = Symbol.for("react.client.reference");
110110
function isValidElementType(type) {
111111
if (typeof type === "string" || typeof type === "function") {
112112
return true;
@@ -138,7 +138,7 @@ if (__DEV__) {
138138
// types supported by any Flight configuration anywhere since
139139
// we don't know which Flight build this will end up being used
140140
// with.
141-
type.$$typeof === REACT_CLIENT_REFERENCE$1 ||
141+
type.$$typeof === REACT_CLIENT_REFERENCE$2 ||
142142
type.getModuleId !== undefined
143143
) {
144144
return true;
@@ -163,24 +163,22 @@ if (__DEV__) {
163163

164164
function getContextName(type) {
165165
return type.displayName || "Context";
166-
} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
166+
}
167+
168+
var REACT_CLIENT_REFERENCE$1 = Symbol.for("react.client.reference"); // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
167169

168170
function getComponentNameFromType(type) {
169171
if (type == null) {
170172
// Host root, text node or just invalid type.
171173
return null;
172174
}
173175

174-
{
175-
if (typeof type.tag === "number") {
176-
error(
177-
"Received an unexpected object in getComponentNameFromType(). " +
178-
"This is likely a bug in React. Please file an issue."
179-
);
176+
if (typeof type === "function") {
177+
if (type.$$typeof === REACT_CLIENT_REFERENCE$1) {
178+
// TODO: Create a convention for naming client references with debug info.
179+
return null;
180180
}
181-
}
182181

183-
if (typeof type === "function") {
184182
return type.displayName || type.name || null;
185183
}
186184

@@ -209,6 +207,15 @@ if (__DEV__) {
209207
}
210208

211209
if (typeof type === "object") {
210+
{
211+
if (typeof type.tag === "number") {
212+
error(
213+
"Received an unexpected object in getComponentNameFromType(). " +
214+
"This is likely a bug in React. Please file an issue."
215+
);
216+
}
217+
}
218+
212219
switch (type.$$typeof) {
213220
case REACT_CONTEXT_TYPE:
214221
var context = type;
@@ -917,10 +924,7 @@ if (__DEV__) {
917924
var info = getDeclarationErrorAddendum();
918925

919926
if (!info) {
920-
var parentName =
921-
typeof parentType === "string"
922-
? parentType
923-
: parentType.displayName || parentType.name;
927+
var parentName = getComponentNameFromType(parentType);
924928

925929
if (parentName) {
926930
info =

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<147cb9c49da614e98a9929adc67f6800>>
10+
* @generated SignedSource<<8fbe3bc0848b0909865f9804f5adcef7>>
1111
*/
1212

1313
"use strict";
@@ -106,7 +106,7 @@ if (__DEV__) {
106106
var enableScopeAPI = false;
107107
var enableTransitionTracing = false;
108108

109-
var REACT_CLIENT_REFERENCE$1 = Symbol.for("react.client.reference");
109+
var REACT_CLIENT_REFERENCE$2 = Symbol.for("react.client.reference");
110110
function isValidElementType(type) {
111111
if (typeof type === "string" || typeof type === "function") {
112112
return true;
@@ -138,7 +138,7 @@ if (__DEV__) {
138138
// types supported by any Flight configuration anywhere since
139139
// we don't know which Flight build this will end up being used
140140
// with.
141-
type.$$typeof === REACT_CLIENT_REFERENCE$1 ||
141+
type.$$typeof === REACT_CLIENT_REFERENCE$2 ||
142142
type.getModuleId !== undefined
143143
) {
144144
return true;
@@ -163,24 +163,22 @@ if (__DEV__) {
163163

164164
function getContextName(type) {
165165
return type.displayName || "Context";
166-
} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
166+
}
167+
168+
var REACT_CLIENT_REFERENCE$1 = Symbol.for("react.client.reference"); // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
167169

168170
function getComponentNameFromType(type) {
169171
if (type == null) {
170172
// Host root, text node or just invalid type.
171173
return null;
172174
}
173175

174-
{
175-
if (typeof type.tag === "number") {
176-
error(
177-
"Received an unexpected object in getComponentNameFromType(). " +
178-
"This is likely a bug in React. Please file an issue."
179-
);
176+
if (typeof type === "function") {
177+
if (type.$$typeof === REACT_CLIENT_REFERENCE$1) {
178+
// TODO: Create a convention for naming client references with debug info.
179+
return null;
180180
}
181-
}
182181

183-
if (typeof type === "function") {
184182
return type.displayName || type.name || null;
185183
}
186184

@@ -209,6 +207,15 @@ if (__DEV__) {
209207
}
210208

211209
if (typeof type === "object") {
210+
{
211+
if (typeof type.tag === "number") {
212+
error(
213+
"Received an unexpected object in getComponentNameFromType(). " +
214+
"This is likely a bug in React. Please file an issue."
215+
);
216+
}
217+
}
218+
212219
switch (type.$$typeof) {
213220
case REACT_CONTEXT_TYPE:
214221
var context = type;
@@ -917,10 +924,7 @@ if (__DEV__) {
917924
var info = getDeclarationErrorAddendum();
918925

919926
if (!info) {
920-
var parentName =
921-
typeof parentType === "string"
922-
? parentType
923-
: parentType.displayName || parentType.name;
927+
var parentName = getComponentNameFromType(parentType);
924928

925929
if (parentName) {
926930
info =

0 commit comments

Comments
 (0)