@@ -36,6 +36,7 @@ let ReactNoopFlightServer;
3636let Scheduler ;
3737let advanceTimersByTime ;
3838let assertLog ;
39+ let assertConsoleErrorDev ;
3940
4041describe ( 'ReactFlight' , ( ) => {
4142 beforeEach ( ( ) => {
@@ -64,6 +65,7 @@ describe('ReactFlight', () => {
6465 Scheduler = require ( 'scheduler' ) ;
6566 const InternalTestUtils = require ( 'internal-test-utils' ) ;
6667 assertLog = InternalTestUtils . assertLog ;
68+ assertConsoleErrorDev = InternalTestUtils . assertConsoleErrorDev ;
6769 } ) ;
6870
6971 afterEach ( ( ) => {
@@ -175,4 +177,26 @@ describe('ReactFlight', () => {
175177 stackTwo : '\n in OwnerStackDelayed (at **)' + '\n in App (at **)' ,
176178 } ) ;
177179 } ) ;
180+
181+ it ( 'logs an error when prod elements are rendered' , async ( ) => {
182+ const element = ReactServer . createElement ( 'span' , {
183+ key : 'one' ,
184+ children : 'Free!' ,
185+ } ) ;
186+ ReactNoopFlightServer . render (
187+ // bad clone
188+ { ...element } ,
189+ ) ;
190+
191+ assertConsoleErrorDev ( [
192+ [
193+ 'Attempted to render <span key="one"> without development properties. This is not supported. It can happen if:' +
194+ '\n- The element is created with a production version of React but rendered in development.' +
195+ '\n- The element was cloned with a custom function instead of `React.cloneElement`.\n' +
196+ "The props of this element may help locate this element: { children: 'Free!', [key]: [Getter] }" ,
197+ { withoutStack : true } ,
198+ ] ,
199+ "TypeError: Cannot read properties of undefined (reading 'stack')" ,
200+ ] ) ;
201+ } ) ;
178202} ) ;
0 commit comments