File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1- import { useLayoutEffect , useState } from 'react' ;
1+ import { useState } from 'react' ;
22import isMobile from '../isMobile' ;
3+ import useLayoutEffect from './useLayoutEffect' ;
34
45/**
56 * Hook to detect if the user is on a mobile device
Original file line number Diff line number Diff line change @@ -518,5 +518,18 @@ describe('hooks', () => {
518518
519519 navigatorSpy . mockRestore ( ) ;
520520 } ) ;
521+
522+ it ( 'should not warn useLayoutEffect in SSR' , ( ) => {
523+ const errorSpy = jest . spyOn ( console , 'error' ) ;
524+ const Demo = ( ) => {
525+ useMobile ( ) ;
526+ return null ;
527+ } ;
528+ renderToString ( < Demo /> ) ;
529+ expect ( errorSpy ) . not . toHaveBeenCalledWith (
530+ expect . stringContaining ( 'useLayoutEffect' ) ,
531+ expect . anything ( ) ,
532+ ) ;
533+ } ) ;
521534 } ) ;
522535} ) ;
You can’t perform that action at this time.
0 commit comments