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', () => {
453
453
'\n in Child (at **)\n in Intermediate (at **)\n in Parent (at **)' ,
454
454
) ;
455
455
} ) ;
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
+ } ) ;
456
468
} ) ;
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ export function patch({
144
144
if ( consoleSettingsRef . appendComponentStack ) {
145
145
const lastArg = args . length > 0 ? args [ args . length - 1 ] : null ;
146
146
const alreadyHasComponentStack =
147
- lastArg !== null && isStringComponentStack ( lastArg ) ;
147
+ typeof lastArg === 'string' && isStringComponentStack ( lastArg ) ;
148
148
149
149
// If we are ever called with a string that already has a component stack,
150
150
// 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}) {
149
149
return [ < div /> ] ;
150
150
}
151
151
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
+
152
158
export default function ErrorsAndWarnings ( ) {
153
159
const [ count , setCount ] = useState ( 0 ) ;
154
160
const handleClick = ( ) => setCount ( count + 1 ) ;
@@ -176,6 +182,7 @@ export default function ErrorsAndWarnings() {
176
182
< ReallyLongErrorMessageThatWillCauseTextToBeTruncated />
177
183
< DuplicateWarningsAndErrors />
178
184
< MultipleWarningsAndErrors />
185
+ < ComponentWithSymbolWarning />
179
186
</ Fragment >
180
187
) ;
181
188
}
You can’t perform that action at this time.
0 commit comments