File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
packages/react-reconciler/src/__tests__ Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -690,16 +690,18 @@ describe('ReactHooks', () => {
690
690
) ;
691
691
} ) ;
692
692
693
- it ( 'throws when reading context inside useMemo after outside it' , ( ) => {
693
+ it ( 'throws when reading context inside useMemo after reading outside it' , ( ) => {
694
694
const { useMemo, createContext} = React ;
695
695
const ReactCurrentDispatcher =
696
696
React . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
697
697
. ReactCurrentDispatcher ;
698
698
699
699
const ThemeContext = createContext ( 'light' ) ;
700
- let firstRead ;
700
+ let firstRead , secondRead ;
701
701
function App ( ) {
702
702
firstRead = ReactCurrentDispatcher . current . readContext ( ThemeContext ) ;
703
+ useMemo ( ( ) => { } ) ;
704
+ secondRead = ReactCurrentDispatcher . current . readContext ( ThemeContext ) ;
703
705
return useMemo ( ( ) => {
704
706
return ReactCurrentDispatcher . current . readContext ( ThemeContext ) ;
705
707
} , [ ] ) ;
@@ -709,6 +711,7 @@ describe('ReactHooks', () => {
709
711
'Context can only be read inside the body of a component' ,
710
712
) ;
711
713
expect ( firstRead ) . toBe ( 'light' ) ;
714
+ expect ( secondRead ) . toBe ( 'light' ) ;
712
715
} ) ;
713
716
714
717
it ( 'throws when reading context inside useEffect' , ( ) => {
You can’t perform that action at this time.
0 commit comments