Skip to content

Commit 355d677

Browse files
committed
Remove method name prefix from warnings and errors (#28432)
This pattern is a petpeeve of mine. I don't consider this best practice and so most don't have these prefixes. Very inconsistent. At best this is useless and noisey that you have to parse because the information is also in the stack trace. At worse these are misleading because they're highlighting something internal (like validateDOMNesting) which even suggests an internal bug. Even the ones public to React aren't necessarily what you called because you might be calling a wrapper around it. That would be properly reflected in a stack trace - which can also properly ignore list so that the first stack you see is your callsite, Which might be like `render()` in react-testing-library rather than `createRoot()` for example. DiffTrain build for commit d579e77.
1 parent 2b0bca0 commit 355d677

File tree

13 files changed

+96
-131
lines changed

13 files changed

+96
-131
lines changed

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

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

1313
"use strict";
@@ -10966,21 +10966,20 @@ if (__DEV__) {
1096610966
Object.freeze(fakeInternalInstance);
1096710967
}
1096810968

10969-
function warnOnInvalidCallback(callback, callerName) {
10969+
function warnOnInvalidCallback(callback) {
1097010970
{
1097110971
if (callback === null || typeof callback === "function") {
1097210972
return;
10973-
}
10973+
} // eslint-disable-next-line react-internal/safe-string-coercion
1097410974

10975-
var key = callerName + "_" + callback;
10975+
var key = String(callback);
1097610976

1097710977
if (!didWarnOnInvalidCallback.has(key)) {
1097810978
didWarnOnInvalidCallback.add(key);
1097910979

1098010980
error(
10981-
"%s(...): Expected the last optional `callback` argument to be a " +
10981+
"Expected the last optional `callback` argument to be a " +
1098210982
"function. Instead received: %s.",
10983-
callerName,
1098410983
callback
1098510984
);
1098610985
}
@@ -11043,7 +11042,7 @@ if (__DEV__) {
1104311042

1104411043
if (callback !== undefined && callback !== null) {
1104511044
{
11046-
warnOnInvalidCallback(callback, "setState");
11045+
warnOnInvalidCallback(callback);
1104711046
}
1104811047

1104911048
update.callback = callback;
@@ -11065,7 +11064,7 @@ if (__DEV__) {
1106511064

1106611065
if (callback !== undefined && callback !== null) {
1106711066
{
11068-
warnOnInvalidCallback(callback, "replaceState");
11067+
warnOnInvalidCallback(callback);
1106911068
}
1107011069

1107111070
update.callback = callback;
@@ -11087,7 +11086,7 @@ if (__DEV__) {
1108711086

1108811087
if (callback !== undefined && callback !== null) {
1108911088
{
11090-
warnOnInvalidCallback(callback, "forceUpdate");
11089+
warnOnInvalidCallback(callback);
1109111090
}
1109211091

1109311092
update.callback = callback;
@@ -11152,13 +11151,13 @@ if (__DEV__) {
1115211151
if (!renderPresent) {
1115311152
if (ctor.prototype && typeof ctor.prototype.render === "function") {
1115411153
error(
11155-
"%s(...): No `render` method found on the returned component " +
11154+
"No `render` method found on the %s " +
1115611155
"instance: did you accidentally return an object from the constructor?",
1115711156
name
1115811157
);
1115911158
} else {
1116011159
error(
11161-
"%s(...): No `render` method found on the returned component " +
11160+
"No `render` method found on the %s " +
1116211161
"instance: you may have forgotten to define `render`.",
1116311162
name
1116411163
);
@@ -11293,9 +11292,8 @@ if (__DEV__) {
1129311292

1129411293
if (instance.props !== undefined && hasMutatedProps) {
1129511294
error(
11296-
"%s(...): When calling super() in `%s`, make sure to pass " +
11295+
"When calling super() in `%s`, make sure to pass " +
1129711296
"up the same props that your component's constructor was passed.",
11298-
name,
1129911297
name
1130011298
);
1130111299
}
@@ -13963,7 +13961,8 @@ if (__DEV__) {
1396313961
if (Component) {
1396413962
if (Component.childContextTypes) {
1396513963
error(
13966-
"%s(...): childContextTypes cannot be defined on a function component.",
13964+
"childContextTypes cannot be defined on a function component.\n" +
13965+
" %s.childContextTypes = ...",
1396713966
Component.displayName || Component.name || "Component"
1396813967
);
1396913968
}
@@ -25728,7 +25727,7 @@ if (__DEV__) {
2572825727
return root;
2572925728
}
2573025729

25731-
var ReactVersion = "18.3.0-canary-8fb0233a8-20240223";
25730+
var ReactVersion = "18.3.0-canary-d579e7748-20240223";
2573225731

2573325732
// Might add PROFILE later.
2573425733

@@ -25825,7 +25824,7 @@ if (__DEV__) {
2582525824
{
2582625825
if (typeof callback !== "function") {
2582725826
error(
25828-
"render(...): Expected the last optional `callback` argument to be a " +
25827+
"Expected the last optional `callback` argument to be a " +
2582925828
"function. Instead received: %s.",
2583025829
callback
2583125830
);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9171,7 +9171,7 @@ var devToolsConfig$jscomp$inline_1014 = {
91719171
throw Error("TestRenderer does not support findFiberByHostInstance()");
91729172
},
91739173
bundleType: 0,
9174-
version: "18.3.0-canary-8fb0233a8-20240223",
9174+
version: "18.3.0-canary-d579e7748-20240223",
91759175
rendererPackageName: "react-test-renderer"
91769176
};
91779177
var internals$jscomp$inline_1195 = {
@@ -9202,7 +9202,7 @@ var internals$jscomp$inline_1195 = {
92029202
scheduleRoot: null,
92039203
setRefreshHandler: null,
92049204
getCurrentFiber: null,
9205-
reconcilerVersion: "18.3.0-canary-8fb0233a8-20240223"
9205+
reconcilerVersion: "18.3.0-canary-d579e7748-20240223"
92069206
};
92079207
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
92089208
var hook$jscomp$inline_1196 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9599,7 +9599,7 @@ var devToolsConfig$jscomp$inline_1056 = {
95999599
throw Error("TestRenderer does not support findFiberByHostInstance()");
96009600
},
96019601
bundleType: 0,
9602-
version: "18.3.0-canary-8fb0233a8-20240223",
9602+
version: "18.3.0-canary-d579e7748-20240223",
96039603
rendererPackageName: "react-test-renderer"
96049604
};
96059605
var internals$jscomp$inline_1236 = {
@@ -9630,7 +9630,7 @@ var internals$jscomp$inline_1236 = {
96309630
scheduleRoot: null,
96319631
setRefreshHandler: null,
96329632
getCurrentFiber: null,
9633-
reconcilerVersion: "18.3.0-canary-8fb0233a8-20240223"
9633+
reconcilerVersion: "18.3.0-canary-d579e7748-20240223"
96349634
};
96359635
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
96369636
var hook$jscomp$inline_1237 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<0ecfa00d9e6316d213c0fcd6bd2fed34>>
10+
* @generated SignedSource<<5829f9269f50c47e26af16e11355c71d>>
1111
*/
1212

1313
"use strict";
@@ -26,7 +26,7 @@ if (__DEV__) {
2626
}
2727
var dynamicFlags = require("ReactNativeInternalFeatureFlags");
2828

29-
var ReactVersion = "18.3.0-canary-8fb0233a8-20240223";
29+
var ReactVersion = "18.3.0-canary-d579e7748-20240223";
3030

3131
// ATTENTION
3232
// When adding new symbols to this file,
@@ -383,7 +383,7 @@ if (__DEV__) {
383383
partialState != null
384384
) {
385385
throw new Error(
386-
"setState(...): takes an object of state variables to update or a " +
386+
"takes an object of state variables to update or a " +
387387
"function which returns an object of state variables."
388388
);
389389
}
@@ -1885,7 +1885,7 @@ if (__DEV__) {
18851885
function cloneElement(element, config, children) {
18861886
if (element === null || element === undefined) {
18871887
throw new Error(
1888-
"React.cloneElement(...): The argument must be a React element, but you passed " +
1888+
"The argument must be a React element, but you passed " +
18891889
element +
18901890
"."
18911891
);
@@ -2806,7 +2806,7 @@ if (__DEV__) {
28062806
// $FlowFixMe[missing-local-annot]
28072807
set: function (newDefaultProps) {
28082808
error(
2809-
"React.lazy(...): It is not supported to assign `defaultProps` to " +
2809+
"It is not supported to assign `defaultProps` to " +
28102810
"a lazy component import. Either specify them where the component " +
28112811
"is defined, or create a wrapping component around it."
28122812
);
@@ -2827,7 +2827,7 @@ if (__DEV__) {
28272827
// $FlowFixMe[missing-local-annot]
28282828
set: function (newPropTypes) {
28292829
error(
2830-
"React.lazy(...): It is not supported to assign `propTypes` to " +
2830+
"It is not supported to assign `propTypes` to " +
28312831
"a lazy component import. Either specify them where the component " +
28322832
"is defined, or create a wrapping component around it."
28332833
);

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js

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

1313
"use strict";
@@ -61,7 +61,7 @@ Component.prototype.setState = function (partialState, callback) {
6161
null != partialState
6262
)
6363
throw Error(
64-
"setState(...): takes an object of state variables to update or a function which returns an object of state variables."
64+
"takes an object of state variables to update or a function which returns an object of state variables."
6565
);
6666
this.updater.enqueueSetState(this, partialState, callback, "setState");
6767
};
@@ -422,9 +422,7 @@ exports.cache = function (fn) {
422422
exports.cloneElement = function (element, config, children) {
423423
if (null === element || void 0 === element)
424424
throw Error(
425-
"React.cloneElement(...): The argument must be a React element, but you passed " +
426-
element +
427-
"."
425+
"The argument must be a React element, but you passed " + element + "."
428426
);
429427
var props = assign({}, element.props),
430428
key = element.key,
@@ -600,4 +598,4 @@ exports.useSyncExternalStore = function (
600598
exports.useTransition = function () {
601599
return ReactCurrentDispatcher.current.useTransition();
602600
};
603-
exports.version = "18.3.0-canary-8fb0233a8-20240223";
601+
exports.version = "18.3.0-canary-d579e7748-20240223";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js

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

1313
"use strict";
@@ -64,7 +64,7 @@ Component.prototype.setState = function (partialState, callback) {
6464
null != partialState
6565
)
6666
throw Error(
67-
"setState(...): takes an object of state variables to update or a function which returns an object of state variables."
67+
"takes an object of state variables to update or a function which returns an object of state variables."
6868
);
6969
this.updater.enqueueSetState(this, partialState, callback, "setState");
7070
};
@@ -389,9 +389,7 @@ exports.cache = function (fn) {
389389
exports.cloneElement = function (element, config, children) {
390390
if (null === element || void 0 === element)
391391
throw Error(
392-
"React.cloneElement(...): The argument must be a React element, but you passed " +
393-
element +
394-
"."
392+
"The argument must be a React element, but you passed " + element + "."
395393
);
396394
var props = assign({}, element.props),
397395
key = element.key,
@@ -596,7 +594,7 @@ exports.useSyncExternalStore = function (
596594
exports.useTransition = function () {
597595
return ReactCurrentDispatcher.current.useTransition();
598596
};
599-
exports.version = "18.3.0-canary-8fb0233a8-20240223";
597+
exports.version = "18.3.0-canary-d579e7748-20240223";
600598
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
601599
"function" ===
602600
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8fb0233a845974b4b1049e54b6c25dc54d6dd173
1+
d579e7748218920331252b0528850943d5e2dd31

0 commit comments

Comments
 (0)