Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/quisido/use-page-transition

React hook for listening to page visibility events
https://github.com/quisido/use-page-transition

Last synced: 20 days ago
JSON representation

React hook for listening to page visibility events

Awesome Lists containing this project

README

        

# usePageTransition [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Listen%20for%20page%20transition%20events%20with%20a%20React%20hook.&url=https://github.com/CharlesStover/use-page-transition&via=CharlesStover&hashtags=react,reactjs,javascript,typescript,webdev,webdevelopment) [![version](https://img.shields.io/npm/v/use-page-transition.svg)](https://www.npmjs.com/package/use-page-transition) [![minzipped size](https://img.shields.io/bundlephobia/minzip/use-page-transition.svg)](https://www.npmjs.com/package/use-page-transition) [![downloads](https://img.shields.io/npm/dt/use-page-transition.svg)](https://www.npmjs.com/package/use-page-transition) [![build](https://api.travis-ci.com/CharlesStover/use-page-transition.svg)](https://travis-ci.com/CharlesStover/use-page-transition/)

Listen for page transition (visibility and persistence) events with a React
hook.

- [Install](#install)
- [Use](#use)
- [Sponsor](#sponsor)

## Install

- `npm install use-page-transition` or
- `yarn add use-page-transition`

## Use

```javascript
function App() {
const [isVisible, isPersistent] = usePageTransition();
return (


The page is {isVisible ? 'visible' : 'hidden'}
{isPersistent ? ' and persisted' : ''}.


);
}
```

## Sponsor 💗

If you are a fan of this project, you may
[become a sponsor](https://github.com/sponsors/CharlesStover)
via GitHub's Sponsors Program.