diff --git a/packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js b/packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js index 0c38e61559..9ee5ef633c 100644 --- a/packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js @@ -1270,6 +1270,29 @@ describe('ReactHooks', () => { ]); expect(ReactNoop.getChildren()).toEqual([]); }); + + it('works with memo', () => { + function Counter({count}) { + useLayoutEffect(() => { + ReactNoop.yield('Mount: ' + count); + return () => ReactNoop.yield('Unmount: ' + count); + }); + return ; + } + Counter = memo(Counter); + + ReactNoop.render(); + expect(ReactNoop.flush()).toEqual(['Count: 0', 'Mount: 0']); + expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]); + + ReactNoop.render(); + expect(ReactNoop.flush()).toEqual(['Count: 1', 'Unmount: 0', 'Mount: 1']); + expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]); + + ReactNoop.render(null); + expect(ReactNoop.flush()).toEqual(['Unmount: 1']); + expect(ReactNoop.getChildren()).toEqual([]); + }); }); describe('useMutationEffect and useLayoutEffect', () => {