Skip to content

Commit 7cb26fb

Browse files
committed
More convoluted test
1 parent 093c8a2 commit 7cb26fb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,16 +690,18 @@ describe('ReactHooks', () => {
690690
);
691691
});
692692

693-
it('throws when reading context inside useMemo after outside it', () => {
693+
it('throws when reading context inside useMemo after reading outside it', () => {
694694
const {useMemo, createContext} = React;
695695
const ReactCurrentDispatcher =
696696
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
697697
.ReactCurrentDispatcher;
698698

699699
const ThemeContext = createContext('light');
700-
let firstRead;
700+
let firstRead, secondRead;
701701
function App() {
702702
firstRead = ReactCurrentDispatcher.current.readContext(ThemeContext);
703+
useMemo(() => {});
704+
secondRead = ReactCurrentDispatcher.current.readContext(ThemeContext);
703705
return useMemo(() => {
704706
return ReactCurrentDispatcher.current.readContext(ThemeContext);
705707
}, []);
@@ -709,6 +711,7 @@ describe('ReactHooks', () => {
709711
'Context can only be read inside the body of a component',
710712
);
711713
expect(firstRead).toBe('light');
714+
expect(secondRead).toBe('light');
712715
});
713716

714717
it('throws when reading context inside useEffect', () => {

0 commit comments

Comments
 (0)