Skip to content

Commit

Permalink
fixing the usePageVisibility triggering renders multiple times (#58)
Browse files Browse the repository at this point in the history
* fixing the usePageVisibility triggering renders multiple times

* bumping the version
  • Loading branch information
parulpriyanka authored and nhardy committed Nov 25, 2019
1 parent 0dbfda9 commit 19661e1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/eslint-plugin/package.json
Expand Up @@ -14,6 +14,7 @@
"private": false,
"license": "MIT",
"scripts": {
"build": "exit 0",
"test": "src/test.js"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/kerosene-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "@kablamo/kerosene-ui",
"version": "0.0.13",
"version": "0.0.14",
"repository": {
"type": "git",
"url": "https://github.com/KablamoOSS/kerosene.git",
Expand Down
4 changes: 2 additions & 2 deletions packages/kerosene-ui/src/hooks/usePageVisibility.ts
Expand Up @@ -16,8 +16,8 @@ export default function usePageVisibility(
export default function usePageVisibility(
useState = true,
): [boolean, React.RefObject<boolean>] | React.RefObject<boolean> {
const [visible, setVisible] = React.useState(false);
const visibility = React.useRef(false);
const [visible, setVisible] = React.useState(!document.hidden);
const visibility = React.useRef(!document.hidden);

const onVisibilityChange = React.useCallback(() => {
// Fallback to `document.hidden=false` if the API is not present
Expand Down

0 comments on commit 19661e1

Please sign in to comment.