@@ -842,12 +842,15 @@ if (__DEV__) {
842
842
return name ;
843
843
}
844
844
845
- case "function" :
845
+ case "function" : {
846
846
if ( value . $$typeof === CLIENT_REFERENCE_TAG ) {
847
847
return describeClientReference ( ) ;
848
848
}
849
849
850
- return "function" ;
850
+ var _name = value . displayName || value . name ;
851
+
852
+ return _name ? "function " + _name : "function" ;
853
+ }
851
854
852
855
default :
853
856
// eslint-disable-next-line react-internal/safe-string-coercion
@@ -1038,9 +1041,9 @@ if (__DEV__) {
1038
1041
str += ", " ;
1039
1042
}
1040
1043
1041
- var _name = _names [ _i3 ] ;
1042
- str += describeKeyForErrorMessage ( _name ) + ": " ;
1043
- var _value3 = _object [ _name ] ;
1044
+ var _name2 = _names [ _i3 ] ;
1045
+ str += describeKeyForErrorMessage ( _name2 ) + ": " ;
1046
+ var _value3 = _object [ _name2 ] ;
1044
1047
1045
1048
var _substr3 = void 0 ;
1046
1049
@@ -1050,7 +1053,7 @@ if (__DEV__) {
1050
1053
_substr3 = describeValueForErrorMessage ( _value3 ) ;
1051
1054
}
1052
1055
1053
- if ( _name === expandedName ) {
1056
+ if ( _name2 === expandedName ) {
1054
1057
start = str . length ;
1055
1058
length = _substr3 . length ;
1056
1059
str += _substr3 ;
@@ -2263,10 +2266,26 @@ if (__DEV__) {
2263
2266
describeObjectForErrorMessage ( parent , parentPropertyName ) +
2264
2267
"\nIf you need interactivity, consider converting part of this to a Client Component."
2265
2268
) ;
2269
+ } else if (
2270
+ jsxChildrenParents . has ( parent ) ||
2271
+ ( jsxPropsParents . has ( parent ) && parentPropertyName === "children" )
2272
+ ) {
2273
+ var componentName = value . displayName || value . name || "Component" ;
2274
+ throw new Error (
2275
+ "Functions are not valid as a child of Client Components. This may happen if " +
2276
+ "you return " +
2277
+ componentName +
2278
+ " instead of <" +
2279
+ componentName +
2280
+ " /> from render. " +
2281
+ "Or maybe you meant to call this function rather than return it." +
2282
+ describeObjectForErrorMessage ( parent , parentPropertyName )
2283
+ ) ;
2266
2284
} else {
2267
2285
throw new Error (
2268
2286
"Functions cannot be passed directly to Client Components " +
2269
- 'unless you explicitly expose it by marking it with "use server".' +
2287
+ 'unless you explicitly expose it by marking it with "use server". ' +
2288
+ "Or maybe you meant to call this function rather than return it." +
2270
2289
describeObjectForErrorMessage ( parent , parentPropertyName )
2271
2290
) ;
2272
2291
}
0 commit comments