@@ -426,6 +426,150 @@ describe('ReactHooksInspection', () => {
426426 ` ) ;
427427 } ) ;
428428
429+ it ( 'should not confuse built-in hooks with custom hooks that have the same name' , ( ) => {
430+ function useState ( value ) {
431+ React . useState ( value ) ;
432+ React . useDebugValue ( 'custom useState' ) ;
433+ }
434+ function useFormStatus ( ) {
435+ React . useState ( 'custom useState' ) ;
436+ React . useDebugValue ( 'custom useFormStatus' ) ;
437+ }
438+ function Foo ( props ) {
439+ useFormStatus ( ) ;
440+ useState ( 'Hello, Dave!' ) ;
441+ return null ;
442+ }
443+ const tree = ReactDebugTools . inspectHooks ( Foo , { } ) ;
444+ if ( __DEV__ ) {
445+ expect ( normalizeSourceLoc ( tree ) ) . toMatchInlineSnapshot ( `
446+ [
447+ {
448+ "debugInfo": null,
449+ "hookSource": {
450+ "columnNumber": 0,
451+ "fileName": "**",
452+ "functionName": "Foo",
453+ "lineNumber": 0,
454+ },
455+ "id": null,
456+ "isStateEditable": false,
457+ "name": "FormStatus",
458+ "subHooks": [
459+ {
460+ "debugInfo": null,
461+ "hookSource": {
462+ "columnNumber": 0,
463+ "fileName": "**",
464+ "functionName": "useFormStatus",
465+ "lineNumber": 0,
466+ },
467+ "id": 0,
468+ "isStateEditable": true,
469+ "name": "State",
470+ "subHooks": [],
471+ "value": "custom useState",
472+ },
473+ ],
474+ "value": "custom useFormStatus",
475+ },
476+ {
477+ "debugInfo": null,
478+ "hookSource": {
479+ "columnNumber": 0,
480+ "fileName": "**",
481+ "functionName": "Foo",
482+ "lineNumber": 0,
483+ },
484+ "id": null,
485+ "isStateEditable": false,
486+ "name": "State",
487+ "subHooks": [
488+ {
489+ "debugInfo": null,
490+ "hookSource": {
491+ "columnNumber": 0,
492+ "fileName": "**",
493+ "functionName": "useState",
494+ "lineNumber": 0,
495+ },
496+ "id": 1,
497+ "isStateEditable": true,
498+ "name": "State",
499+ "subHooks": [],
500+ "value": "Hello, Dave!",
501+ },
502+ ],
503+ "value": "custom useState",
504+ },
505+ ]
506+ ` ) ;
507+ } else {
508+ expect ( normalizeSourceLoc ( tree ) ) . toMatchInlineSnapshot ( `
509+ [
510+ {
511+ "debugInfo": null,
512+ "hookSource": {
513+ "columnNumber": 0,
514+ "fileName": "**",
515+ "functionName": "Foo",
516+ "lineNumber": 0,
517+ },
518+ "id": null,
519+ "isStateEditable": false,
520+ "name": "FormStatus",
521+ "subHooks": [
522+ {
523+ "debugInfo": null,
524+ "hookSource": {
525+ "columnNumber": 0,
526+ "fileName": "**",
527+ "functionName": "useFormStatus",
528+ "lineNumber": 0,
529+ },
530+ "id": 0,
531+ "isStateEditable": true,
532+ "name": "State",
533+ "subHooks": [],
534+ "value": "custom useState",
535+ },
536+ ],
537+ "value": undefined,
538+ },
539+ {
540+ "debugInfo": null,
541+ "hookSource": {
542+ "columnNumber": 0,
543+ "fileName": "**",
544+ "functionName": "Foo",
545+ "lineNumber": 0,
546+ },
547+ "id": null,
548+ "isStateEditable": false,
549+ "name": "State",
550+ "subHooks": [
551+ {
552+ "debugInfo": null,
553+ "hookSource": {
554+ "columnNumber": 0,
555+ "fileName": "**",
556+ "functionName": "useState",
557+ "lineNumber": 0,
558+ },
559+ "id": 1,
560+ "isStateEditable": true,
561+ "name": "State",
562+ "subHooks": [],
563+ "value": "Hello, Dave!",
564+ },
565+ ],
566+ "value": undefined,
567+ },
568+ ]
569+ ` ) ;
570+ }
571+ } ) ;
572+
429573 it ( 'should inspect the default value using the useContext hook' , ( ) => {
430574 const MyContext = React . createContext ( 'default' ) ;
431575 function Foo ( props ) {
0 commit comments