import React, { memo, useContext } from 'react'; import { fireEvent, pureRender } from '../../../tests/utils'; import Menu from '../index'; import MenuContext from '../MenuContext'; let innerCount = 0; let outerCount = 0; const handleClick = () => { outerCount++; }; // we use'memo' here in order to only render inner component while context changed. const CacheInner: React.FC = memo(() => { innerCount++; // subscribe locale context useContext(MenuContext); return null; }); const CacheOuter: React.FC = memo(() => ( <>
> )); it("Rendering on Menu without changed MenuContext won't trigger rendering on child component.", () => { const { container, unmount } = pureRender(