@@ -833,6 +833,44 @@ describe('ReactHooksInspectionIntegration', () => {
833833 ` ) ;
834834 } ) ;
835835
836+ it ( 'should inspect the value of the current provider in useContext reading the same context multiple times' , async ( ) => {
837+ const ContextA = React . createContext ( 'default A' ) ;
838+ const ContextB = React . createContext ( 'default B' ) ;
839+ function Foo ( props ) {
840+ React . useContext ( ContextA ) ;
841+ React . useContext ( ContextA ) ;
842+ React . useContext ( ContextB ) ;
843+ React . useContext ( ContextB ) ;
844+ React . useContext ( ContextA ) ;
845+ React . useContext ( ContextB ) ;
846+ React . useContext ( ContextB ) ;
847+ React . useContext ( ContextB ) ;
848+ return null ;
849+ }
850+ let renderer ;
851+ await act ( ( ) => {
852+ renderer = ReactTestRenderer . create (
853+ < ContextA . Provider value = "contextual A" >
854+ < Foo prop = "prop" />
855+ </ ContextA . Provider > ,
856+ { unstable_isConcurrent : true } ,
857+ ) ;
858+ } ) ;
859+ const childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
860+ const tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
861+
862+ expect ( normalizeSourceLoc ( tree ) ) . toEqual ( [
863+ expect . objectContaining ( { value : 'contextual A' } ) ,
864+ expect . objectContaining ( { value : 'contextual A' } ) ,
865+ expect . objectContaining ( { value : 'default B' } ) ,
866+ expect . objectContaining ( { value : 'default B' } ) ,
867+ expect . objectContaining ( { value : 'contextual A' } ) ,
868+ expect . objectContaining ( { value : 'default B' } ) ,
869+ expect . objectContaining ( { value : 'default B' } ) ,
870+ expect . objectContaining ( { value : 'default B' } ) ,
871+ ] ) ;
872+ } ) ;
873+
836874 it ( 'should inspect forwardRef' , async ( ) => {
837875 const obj = function ( ) { } ;
838876 const Foo = React . forwardRef ( function ( props , ref ) {
0 commit comments