File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed
packages/react-error-overlay/src Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change 33type ReactFrame = {
44 fileName : string | null ,
55 lineNumber : number | null ,
6- functionName : string | null ,
6+ name : string | null ,
77} ;
88const reactFrameStack : Array < ReactFrame [ ] > = [ ] ;
99
1010export type { ReactFrame } ;
1111
12+ // This is a stripped down barebones version of this proposal:
13+ // https://gist.github.com/sebmarkbage/bdefa100f19345229d526d0fdd22830f
14+ // We're implementing just enough to get the invalid element type warnings
15+ // to display the component stack in React 15.6+:
16+ // https://github.com/facebook/react/pull/9679
17+ /// TODO: a more comprehensive implementation.
18+
1219const registerReactStack = ( ) => {
1320 // $FlowFixMe
14- console . stack = frames => reactFrameStack . push ( frames ) ;
21+ console . reactStack = frames => reactFrameStack . push ( frames ) ;
1522 // $FlowFixMe
16- console . stackEnd = frames => reactFrameStack . pop ( ) ;
23+ console . reactStackEnd = frames => reactFrameStack . pop ( ) ;
1724} ;
1825
1926const unregisterReactStack = ( ) => {
2027 // $FlowFixMe
21- console . stack = undefined ;
28+ console . reactStack = undefined ;
2229 // $FlowFixMe
23- console . stackEnd = undefined ;
30+ console . reactStackEnd = undefined ;
2431} ;
2532
2633type ConsoleProxyCallback = ( message : string , frames : ReactFrame [ ] ) => void ;
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ function massage(
3333 lastFilename = fileName ;
3434 lastLineNumber = lineNumber ;
3535
36- let { functionName } = frames [ index ] ;
37- functionName = functionName || '(anonymous function)' ;
38- stack += `in ${ functionName } (at ${ fileName } :${ lineNumber } )\n` ;
36+ let { name } = frames [ index ] ;
37+ name = name || '(anonymous function)' ;
38+ stack += `in ${ name } (at ${ fileName } :${ lineNumber } )\n` ;
3939 }
4040
4141 return { message, stack } ;
You can’t perform that action at this time.
0 commit comments