File tree Expand file tree Collapse file tree
packages/react-reconciler/src/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1270,6 +1270,29 @@ describe('ReactHooks', () => {
12701270 ] ) ;
12711271 expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
12721272 } ) ;
1273+
1274+ it ( 'works with memo' , ( ) => {
1275+ function Counter ( { count} ) {
1276+ useLayoutEffect ( ( ) => {
1277+ ReactNoop . yield ( 'Mount: ' + count ) ;
1278+ return ( ) => ReactNoop . yield ( 'Unmount: ' + count ) ;
1279+ } ) ;
1280+ return < Text text = { 'Count: ' + count } /> ;
1281+ }
1282+ Counter = memo ( Counter ) ;
1283+
1284+ ReactNoop . render ( < Counter count = { 0 } /> ) ;
1285+ expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Count: 0' , 'Mount: 0' ] ) ;
1286+ expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Count: 0' ) ] ) ;
1287+
1288+ ReactNoop . render ( < Counter count = { 1 } /> ) ;
1289+ expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Count: 1' , 'Unmount: 0' , 'Mount: 1' ] ) ;
1290+ expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Count: 1' ) ] ) ;
1291+
1292+ ReactNoop . render ( null ) ;
1293+ expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Unmount: 1' ] ) ;
1294+ expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
1295+ } ) ;
12731296 } ) ;
12741297
12751298 describe ( 'useMutationEffect and useLayoutEffect' , ( ) => {
You can’t perform that action at this time.
0 commit comments