Skip to content

Commit d7e7f6c

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 [d579e77](d579e77)
1 parent 6535b04 commit d7e7f6c

28 files changed

+300
-369
lines changed

compiled/facebook-www/REVISION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8fb0233a845974b4b1049e54b6c25dc54d6dd173
1+
d579e7748218920331252b0528850943d5e2dd31

compiled/facebook-www/React-dev.classic.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (__DEV__) {
2424
) {
2525
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2626
}
27-
var ReactVersion = "18.3.0-www-classic-b8eb15b2";
27+
var ReactVersion = "18.3.0-www-classic-7910dce1";
2828

2929
// ATTENTION
3030
// When adding new symbols to this file,
@@ -289,7 +289,7 @@ if (__DEV__) {
289289
partialState != null
290290
) {
291291
throw new Error(
292-
"setState(...): takes an object of state variables to update or a " +
292+
"takes an object of state variables to update or a " +
293293
"function which returns an object of state variables."
294294
);
295295
}
@@ -1932,7 +1932,7 @@ if (__DEV__) {
19321932
function cloneElement(element, config, children) {
19331933
if (element === null || element === undefined) {
19341934
throw new Error(
1935-
"React.cloneElement(...): The argument must be a React element, but you passed " +
1935+
"The argument must be a React element, but you passed " +
19361936
element +
19371937
"."
19381938
);
@@ -2859,7 +2859,7 @@ if (__DEV__) {
28592859
// $FlowFixMe[missing-local-annot]
28602860
set: function (newDefaultProps) {
28612861
error(
2862-
"React.lazy(...): It is not supported to assign `defaultProps` to " +
2862+
"It is not supported to assign `defaultProps` to " +
28632863
"a lazy component import. Either specify them where the component " +
28642864
"is defined, or create a wrapping component around it."
28652865
);
@@ -2880,7 +2880,7 @@ if (__DEV__) {
28802880
// $FlowFixMe[missing-local-annot]
28812881
set: function (newPropTypes) {
28822882
error(
2883-
"React.lazy(...): It is not supported to assign `propTypes` to " +
2883+
"It is not supported to assign `propTypes` to " +
28842884
"a lazy component import. Either specify them where the component " +
28852885
"is defined, or create a wrapping component around it."
28862886
);

compiled/facebook-www/React-dev.modern.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (__DEV__) {
2424
) {
2525
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2626
}
27-
var ReactVersion = "18.3.0-www-modern-5ca55b0c";
27+
var ReactVersion = "18.3.0-www-modern-a1866c69";
2828

2929
// ATTENTION
3030
// When adding new symbols to this file,
@@ -289,7 +289,7 @@ if (__DEV__) {
289289
partialState != null
290290
) {
291291
throw new Error(
292-
"setState(...): takes an object of state variables to update or a " +
292+
"takes an object of state variables to update or a " +
293293
"function which returns an object of state variables."
294294
);
295295
}
@@ -1888,7 +1888,7 @@ if (__DEV__) {
18881888
function cloneElement(element, config, children) {
18891889
if (element === null || element === undefined) {
18901890
throw new Error(
1891-
"React.cloneElement(...): The argument must be a React element, but you passed " +
1891+
"The argument must be a React element, but you passed " +
18921892
element +
18931893
"."
18941894
);
@@ -2815,7 +2815,7 @@ if (__DEV__) {
28152815
// $FlowFixMe[missing-local-annot]
28162816
set: function (newDefaultProps) {
28172817
error(
2818-
"React.lazy(...): It is not supported to assign `defaultProps` to " +
2818+
"It is not supported to assign `defaultProps` to " +
28192819
"a lazy component import. Either specify them where the component " +
28202820
"is defined, or create a wrapping component around it."
28212821
);
@@ -2836,7 +2836,7 @@ if (__DEV__) {
28362836
// $FlowFixMe[missing-local-annot]
28372837
set: function (newPropTypes) {
28382838
error(
2839-
"React.lazy(...): It is not supported to assign `propTypes` to " +
2839+
"It is not supported to assign `propTypes` to " +
28402840
"a lazy component import. Either specify them where the component " +
28412841
"is defined, or create a wrapping component around it."
28422842
);

compiled/facebook-www/React-prod.classic.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Component.prototype.setState = function (partialState, callback) {
6262
null != partialState
6363
)
6464
throw Error(
65-
"setState(...): takes an object of state variables to update or a function which returns an object of state variables."
65+
"takes an object of state variables to update or a function which returns an object of state variables."
6666
);
6767
this.updater.enqueueSetState(this, partialState, callback, "setState");
6868
};
@@ -433,9 +433,7 @@ exports.cache = function (fn) {
433433
exports.cloneElement = function (element, config, children) {
434434
if (null === element || void 0 === element)
435435
throw Error(
436-
"React.cloneElement(...): The argument must be a React element, but you passed " +
437-
element +
438-
"."
436+
"The argument must be a React element, but you passed " + element + "."
439437
);
440438
var props = assign({}, element.props),
441439
key = element.key,
@@ -635,4 +633,4 @@ exports.useSyncExternalStore = function (
635633
exports.useTransition = function () {
636634
return ReactCurrentDispatcher.current.useTransition();
637635
};
638-
exports.version = "18.3.0-www-classic-59a8d1a0";
636+
exports.version = "18.3.0-www-classic-16574b61";

compiled/facebook-www/React-prod.modern.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -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
};
@@ -394,9 +394,7 @@ exports.cache = function (fn) {
394394
exports.cloneElement = function (element, config, children) {
395395
if (null === element || void 0 === element)
396396
throw Error(
397-
"React.cloneElement(...): The argument must be a React element, but you passed " +
398-
element +
399-
"."
397+
"The argument must be a React element, but you passed " + element + "."
400398
);
401399
var props = assign({}, element.props),
402400
key = element.key,
@@ -627,4 +625,4 @@ exports.useSyncExternalStore = function (
627625
exports.useTransition = function () {
628626
return ReactCurrentDispatcher.current.useTransition();
629627
};
630-
exports.version = "18.3.0-www-modern-16a3d0dd";
628+
exports.version = "18.3.0-www-modern-9a917e2a";

compiled/facebook-www/React-profiling.classic.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Component.prototype.setState = function (partialState, callback) {
6666
null != partialState
6767
)
6868
throw Error(
69-
"setState(...): takes an object of state variables to update or a function which returns an object of state variables."
69+
"takes an object of state variables to update or a function which returns an object of state variables."
7070
);
7171
this.updater.enqueueSetState(this, partialState, callback, "setState");
7272
};
@@ -437,9 +437,7 @@ exports.cache = function (fn) {
437437
exports.cloneElement = function (element, config, children) {
438438
if (null === element || void 0 === element)
439439
throw Error(
440-
"React.cloneElement(...): The argument must be a React element, but you passed " +
441-
element +
442-
"."
440+
"The argument must be a React element, but you passed " + element + "."
443441
);
444442
var props = assign({}, element.props),
445443
key = element.key,
@@ -639,7 +637,7 @@ exports.useSyncExternalStore = function (
639637
exports.useTransition = function () {
640638
return ReactCurrentDispatcher.current.useTransition();
641639
};
642-
exports.version = "18.3.0-www-classic-d95f23f2";
640+
exports.version = "18.3.0-www-classic-3a8f9fbb";
643641
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
644642
"function" ===
645643
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Component.prototype.setState = function (partialState, callback) {
6565
null != partialState
6666
)
6767
throw Error(
68-
"setState(...): takes an object of state variables to update or a function which returns an object of state variables."
68+
"takes an object of state variables to update or a function which returns an object of state variables."
6969
);
7070
this.updater.enqueueSetState(this, partialState, callback, "setState");
7171
};
@@ -398,9 +398,7 @@ exports.cache = function (fn) {
398398
exports.cloneElement = function (element, config, children) {
399399
if (null === element || void 0 === element)
400400
throw Error(
401-
"React.cloneElement(...): The argument must be a React element, but you passed " +
402-
element +
403-
"."
401+
"The argument must be a React element, but you passed " + element + "."
404402
);
405403
var props = assign({}, element.props),
406404
key = element.key,
@@ -631,7 +629,7 @@ exports.useSyncExternalStore = function (
631629
exports.useTransition = function () {
632630
return ReactCurrentDispatcher.current.useTransition();
633631
};
634-
exports.version = "18.3.0-www-modern-12626cf3";
632+
exports.version = "18.3.0-www-modern-1944f24a";
635633
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
636634
"function" ===
637635
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

+14-15
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if (__DEV__) {
6666
return self;
6767
}
6868

69-
var ReactVersion = "18.3.0-www-classic-f7f3772e";
69+
var ReactVersion = "18.3.0-www-classic-b340e372";
7070

7171
var LegacyRoot = 0;
7272
var ConcurrentRoot = 1;
@@ -12626,21 +12626,20 @@ if (__DEV__) {
1262612626
Object.freeze(fakeInternalInstance);
1262712627
}
1262812628

12629-
function warnOnInvalidCallback(callback, callerName) {
12629+
function warnOnInvalidCallback(callback) {
1263012630
{
1263112631
if (callback === null || typeof callback === "function") {
1263212632
return;
12633-
}
12633+
} // eslint-disable-next-line react-internal/safe-string-coercion
1263412634

12635-
var key = callerName + "_" + callback;
12635+
var key = String(callback);
1263612636

1263712637
if (!didWarnOnInvalidCallback.has(key)) {
1263812638
didWarnOnInvalidCallback.add(key);
1263912639

1264012640
error(
12641-
"%s(...): Expected the last optional `callback` argument to be a " +
12641+
"Expected the last optional `callback` argument to be a " +
1264212642
"function. Instead received: %s.",
12643-
callerName,
1264412643
callback
1264512644
);
1264612645
}
@@ -12714,7 +12713,7 @@ if (__DEV__) {
1271412713

1271512714
if (callback !== undefined && callback !== null) {
1271612715
{
12717-
warnOnInvalidCallback(callback, "setState");
12716+
warnOnInvalidCallback(callback);
1271812717
}
1271912718

1272012719
update.callback = callback;
@@ -12749,7 +12748,7 @@ if (__DEV__) {
1274912748

1275012749
if (callback !== undefined && callback !== null) {
1275112750
{
12752-
warnOnInvalidCallback(callback, "replaceState");
12751+
warnOnInvalidCallback(callback);
1275312752
}
1275412753

1275512754
update.callback = callback;
@@ -12784,7 +12783,7 @@ if (__DEV__) {
1278412783

1278512784
if (callback !== undefined && callback !== null) {
1278612785
{
12787-
warnOnInvalidCallback(callback, "forceUpdate");
12786+
warnOnInvalidCallback(callback);
1278812787
}
1278912788

1279012789
update.callback = callback;
@@ -12877,13 +12876,13 @@ if (__DEV__) {
1287712876
if (!renderPresent) {
1287812877
if (ctor.prototype && typeof ctor.prototype.render === "function") {
1287912878
error(
12880-
"%s(...): No `render` method found on the returned component " +
12879+
"No `render` method found on the %s " +
1288112880
"instance: did you accidentally return an object from the constructor?",
1288212881
name
1288312882
);
1288412883
} else {
1288512884
error(
12886-
"%s(...): No `render` method found on the returned component " +
12885+
"No `render` method found on the %s " +
1288712886
"instance: you may have forgotten to define `render`.",
1288812887
name
1288912888
);
@@ -13018,9 +13017,8 @@ if (__DEV__) {
1301813017

1301913018
if (instance.props !== undefined && hasMutatedProps) {
1302013019
error(
13021-
"%s(...): When calling super() in `%s`, make sure to pass " +
13020+
"When calling super() in `%s`, make sure to pass " +
1302213021
"up the same props that your component's constructor was passed.",
13023-
name,
1302413022
name
1302513023
);
1302613024
}
@@ -16065,7 +16063,8 @@ if (__DEV__) {
1606516063
if (Component) {
1606616064
if (Component.childContextTypes) {
1606716065
error(
16068-
"%s(...): childContextTypes cannot be defined on a function component.",
16066+
"childContextTypes cannot be defined on a function component.\n" +
16067+
" %s.childContextTypes = ...",
1606916068
Component.displayName || Component.name || "Component"
1607016069
);
1607116070
}
@@ -30184,7 +30183,7 @@ if (__DEV__) {
3018430183
{
3018530184
if (typeof callback !== "function") {
3018630185
error(
30187-
"render(...): Expected the last optional `callback` argument to be a " +
30186+
"Expected the last optional `callback` argument to be a " +
3018830187
"function. Instead received: %s.",
3018930188
callback
3019030189
);

0 commit comments

Comments
 (0)