Skip to content

Commit

Permalink
More convoluted test
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jan 22, 2019
1 parent 093c8a2 commit 700680a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,11 @@ describe('ReactHooks', () => {
.ReactCurrentDispatcher;

const ThemeContext = createContext('light');
let firstRead;
let firstRead, secondRead;
function App() {
firstRead = ReactCurrentDispatcher.current.readContext(ThemeContext);
useMemo(() => {});
secondRead = ReactCurrentDispatcher.current.readContext(ThemeContext);
return useMemo(() => {
return ReactCurrentDispatcher.current.readContext(ThemeContext);
}, []);
Expand All @@ -709,6 +711,7 @@ describe('ReactHooks', () => {
'Context can only be read inside the body of a component',
);
expect(firstRead).toBe('light');
expect(secondRead).toBe('light');
});

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

0 comments on commit 700680a

Please sign in to comment.