1.0.14 • Published 2 years ago

@heyanniemoran/use-document-visibility v1.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

use-document-visibility

NPM JavaScript Style Guide

Install

npm i @heyanniemoran/use-document-visibility

Usage

import React, { useEffect } from 'react'
import useDocumentVisibility from '@heyanniemoran/use-document-visibility'

const LeaveTabCounter = () => {
  const { count, visible, onVisibilityChange } = useDocumentVisibility();

  useEffect(() => {
    onVisibilityChange((isVisible) => {
      console.log('first handler', isVisible)
    });
    onVisibilityChange((isVisible) => {
      console.log('second handler', isVisible)
    });
  }, [])

  return (
    <div>
      <span>
        Вы покинули страницу: {count} раз
        Вкладка активна? {visible ? 'да' : 'нет'}
      </span>
    </div>
  );
};

License

MIT © heyanniemoran


This hook is created using create-react-hook.

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago