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