File tree 2 files changed +15
-8
lines changed
packages/react-error-overlay/src
2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change 3
3
type ReactFrame = {
4
4
fileName : string | null ,
5
5
lineNumber : number | null ,
6
- functionName : string | null ,
6
+ name : string | null ,
7
7
} ;
8
8
const reactFrameStack : Array < ReactFrame [ ] > = [ ] ;
9
9
10
10
export type { ReactFrame } ;
11
11
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
+
12
19
const registerReactStack = ( ) => {
13
20
// $FlowFixMe
14
- console . stack = frames => reactFrameStack . push ( frames ) ;
21
+ console . reactStack = frames => reactFrameStack . push ( frames ) ;
15
22
// $FlowFixMe
16
- console . stackEnd = frames => reactFrameStack . pop ( ) ;
23
+ console . reactStackEnd = frames => reactFrameStack . pop ( ) ;
17
24
} ;
18
25
19
26
const unregisterReactStack = ( ) => {
20
27
// $FlowFixMe
21
- console . stack = undefined ;
28
+ console . reactStack = undefined ;
22
29
// $FlowFixMe
23
- console . stackEnd = undefined ;
30
+ console . reactStackEnd = undefined ;
24
31
} ;
25
32
26
33
type ConsoleProxyCallback = ( message : string , frames : ReactFrame [ ] ) => void ;
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ function massage(
33
33
lastFilename = fileName ;
34
34
lastLineNumber = lineNumber ;
35
35
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` ;
39
39
}
40
40
41
41
return { message, stack } ;
You can’t perform that action at this time.
0 commit comments