- 
      
 - 
        
Save sandeshdamkondwar/f42a4b3923e98b10c9782dbaf338dfbe to your computer and use it in GitHub Desktop.  
Revisions
- 
        
viclafouch renamed this gist
Jun 16, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // hooks/use-page-visibility.js import { useState, useLayoutEffect } from 'react' function usePageVisibility() {  - 
        
viclafouch revised this gist
Jun 16, 2020 . No changes.There are no files selected for viewing
 - 
        
viclafouch revised this gist
Jun 16, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // hooks/use-visibility-page.js import { useState, useLayoutEffect } from 'react' function usePageVisibility() {  - 
        
viclafouch renamed this gist
Jun 16, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
viclafouch revised this gist
Jun 16, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ import { useState, useLayoutEffect } from 'react' function usePageVisibility() { const [isPageVisible, setIsPageVisible] = useState(!document.hidden) useLayoutEffect(() => { @@ -16,4 +16,4 @@ function useVisibilityPage() { return { isPageVisible } } export default usePageVisibility  - 
        
viclafouch created this gist
Jun 16, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ import { useState, useLayoutEffect } from 'react' function useVisibilityPage() { const [isPageVisible, setIsPageVisible] = useState(!document.hidden) useLayoutEffect(() => { const handleVisibility = () => { setIsPageVisible(!document.hidden) } document.addEventListener('visibilitychange', handleVisibility) return () => { document.removeEventListener('visibilitychange', handleVisibility) } }, []) return { isPageVisible } } export default useVisibilityPage