File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
react-devtools-shared/src
react-devtools-shell/src/app/InlineWarnings Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -453,4 +453,16 @@ describe('console', () => {
453453 '\n in Child (at **)\n in Intermediate (at **)\n in Parent (at **)' ,
454454 ) ;
455455 } ) ;
456+
457+ it ( 'should correctly log Symbols' , ( ) => {
458+ const Component = ( { children} ) => {
459+ fakeConsole . warn ( 'Symbol:' , Symbol ( '' ) ) ;
460+ return null ;
461+ } ;
462+
463+ act ( ( ) => ReactDOM . render ( < Component /> , document . createElement ( 'div' ) ) ) ;
464+
465+ expect ( mockWarn ) . toHaveBeenCalledTimes ( 1 ) ;
466+ expect ( mockWarn . mock . calls [ 0 ] [ 0 ] ) . toBe ( 'Symbol:' ) ;
467+ } ) ;
456468} ) ;
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ export function patch({
144144 if ( consoleSettingsRef . appendComponentStack ) {
145145 const lastArg = args . length > 0 ? args [ args . length - 1 ] : null ;
146146 const alreadyHasComponentStack =
147- lastArg !== null && isStringComponentStack ( lastArg ) ;
147+ typeof lastArg === 'string' && isStringComponentStack ( lastArg ) ;
148148
149149 // If we are ever called with a string that already has a component stack,
150150 // e.g. a React error/warning, don't append a second stack.
Original file line number Diff line number Diff line change @@ -149,6 +149,12 @@ function ComponentWithMissingKey({children}) {
149149 return [ < div /> ] ;
150150}
151151
152+ function ComponentWithSymbolWarning ( ) {
153+ console . warn ( 'this is a symbol' , Symbol ( 'foo' ) ) ;
154+ console . error ( 'this is a symbol' , Symbol . for ( 'bar' ) ) ;
155+ return null ;
156+ }
157+
152158export default function ErrorsAndWarnings ( ) {
153159 const [ count , setCount ] = useState ( 0 ) ;
154160 const handleClick = ( ) => setCount ( count + 1 ) ;
@@ -176,6 +182,7 @@ export default function ErrorsAndWarnings() {
176182 < ReallyLongErrorMessageThatWillCauseTextToBeTruncated />
177183 < DuplicateWarningsAndErrors />
178184 < MultipleWarningsAndErrors />
185+ < ComponentWithSymbolWarning />
179186 </ Fragment >
180187 ) ;
181188}
You can’t perform that action at this time.
0 commit comments