@@ -569,7 +569,7 @@ export type HooksNode = {
569
569
value : mixed ,
570
570
subHooks : Array < HooksNode > ,
571
571
debugInfo : null | ReactDebugInfo ,
572
- hookSource ? : HookSource ,
572
+ hookSource : null | HookSource ,
573
573
} ;
574
574
export type HooksTree = Array< HooksNode > ;
575
575
@@ -716,7 +716,6 @@ function parseCustomHookName(functionName: void | string): string {
716
716
function buildTree (
717
717
rootStack : any ,
718
718
readHookLog : Array < HookLogEntry > ,
719
- includeHooksSource: boolean,
720
719
): HooksTree {
721
720
const rootChildren : Array < HooksNode > = [ ] ;
722
721
let prevStack = null ;
@@ -760,16 +759,13 @@ function buildTree(
760
759
value : undefined ,
761
760
subHooks : children ,
762
761
debugInfo : null ,
763
- } ;
764
-
765
- if ( includeHooksSource ) {
766
- levelChild . hookSource = {
762
+ hookSource : {
767
763
lineNumber : stackFrame . lineNumber ,
768
764
columnNumber : stackFrame . columnNumber ,
769
765
functionName : stackFrame . functionName ,
770
766
fileName : stackFrame . fileName ,
771
- } ;
772
- }
767
+ } ,
768
+ } ;
773
769
774
770
levelChildren . push ( levelChild ) ;
775
771
stackOfChildren . push ( levelChildren ) ;
@@ -800,26 +796,25 @@ function buildTree(
800
796
value : hook . value ,
801
797
subHooks : [ ] ,
802
798
debugInfo : debugInfo ,
799
+ hookSource : null ,
803
800
} ;
804
801
805
- if ( includeHooksSource ) {
806
- const hookSource : HookSource = {
807
- lineNumber : null ,
808
- functionName : null ,
809
- fileName : null ,
810
- columnNumber : null ,
811
- } ;
812
- if ( stack && stack . length >= 1 ) {
813
- const stackFrame = stack [ 0 ] ;
814
- hookSource . lineNumber = stackFrame . lineNumber ;
815
- hookSource . functionName = stackFrame . functionName ;
816
- hookSource . fileName = stackFrame . fileName ;
817
- hookSource . columnNumber = stackFrame . columnNumber ;
818
- }
819
-
820
- levelChild . hookSource = hookSource ;
802
+ const hookSource: HookSource = {
803
+ lineNumber : null ,
804
+ functionName : null ,
805
+ fileName : null ,
806
+ columnNumber : null ,
807
+ } ;
808
+ if (stack && stack . length >= 1 ) {
809
+ const stackFrame = stack [ 0 ] ;
810
+ hookSource . lineNumber = stackFrame . lineNumber ;
811
+ hookSource . functionName = stackFrame . functionName ;
812
+ hookSource . fileName = stackFrame . fileName ;
813
+ hookSource . columnNumber = stackFrame . columnNumber ;
821
814
}
822
815
816
+ levelChild.hookSource = hookSource;
817
+
823
818
levelChildren.push(levelChild);
824
819
}
825
820
@@ -897,7 +892,6 @@ export function inspectHooks<Props>(
897
892
renderFunction: Props => React$Node ,
898
893
props : Props ,
899
894
currentDispatcher : ?CurrentDispatcherRef ,
900
- includeHooksSource : boolean = false ,
901
895
) : HooksTree {
902
896
// DevTools will pass the current renderer's injected dispatcher.
903
897
// Other apps might compile debug hooks as part of their app though.
@@ -923,7 +917,7 @@ export function inspectHooks<Props>(
923
917
currentDispatcher . current = previousDispatcher ;
924
918
}
925
919
const rootStack = ErrorStackParser.parse(ancestorStackError);
926
- return buildTree ( rootStack , readHookLog , includeHooksSource ) ;
920
+ return buildTree(rootStack, readHookLog);
927
921
}
928
922
929
923
function setupContexts ( contextMap : Map < ReactContext < any > , any> , fiber : Fiber ) {
@@ -955,7 +949,6 @@ function inspectHooksOfForwardRef<Props, Ref>(
955
949
props : Props ,
956
950
ref : Ref ,
957
951
currentDispatcher : CurrentDispatcherRef ,
958
- includeHooksSource : boolean ,
959
952
) : HooksTree {
960
953
const previousDispatcher = currentDispatcher . current ;
961
954
let readHookLog ;
@@ -972,7 +965,7 @@ function inspectHooksOfForwardRef<Props, Ref>(
972
965
currentDispatcher . current = previousDispatcher ;
973
966
}
974
967
const rootStack = ErrorStackParser.parse(ancestorStackError);
975
- return buildTree ( rootStack , readHookLog , includeHooksSource ) ;
968
+ return buildTree(rootStack, readHookLog);
976
969
}
977
970
978
971
function resolveDefaultProps ( Component : any , baseProps : any ) {
@@ -993,7 +986,6 @@ function resolveDefaultProps(Component: any, baseProps: any) {
993
986
export function inspectHooksOfFiber (
994
987
fiber : Fiber ,
995
988
currentDispatcher : ?CurrentDispatcherRef ,
996
- includeHooksSource : boolean = false ,
997
989
) : HooksTree {
998
990
// DevTools will pass the current renderer's injected dispatcher.
999
991
// Other apps might compile debug hooks as part of their app though.
@@ -1035,11 +1027,10 @@ export function inspectHooksOfFiber(
1035
1027
props ,
1036
1028
fiber . ref ,
1037
1029
currentDispatcher ,
1038
- includeHooksSource ,
1039
1030
) ;
1040
1031
}
1041
1032
1042
- return inspectHooks ( type , props, currentDispatcher, includeHooksSource ) ;
1033
+ return inspectHooks(type, props, currentDispatcher);
1043
1034
} finally {
1044
1035
currentFiber = null ;
1045
1036
currentHook = null ;
0 commit comments