react-hook-viewport-visibility

1.0.4 • Public • Published

react-hook-viewport-visibility 🙈

A React hook for detecting viewport visibility state.

Installation

Using npm:

npm install --save react-hook-viewport-visibility

Using yarn:

yarn add react-hook-viewport-visibility

Usage

import React from 'react'
import useViewportVisibility from 'react-hook-viewport-visibility'

const ComponentWithViewportVisibility = () => {
  const viewportVisibility = useViewportVisibility()
  
  return (
    <p>Viewport visibility: {viewportVisibility}</p>
  )
}

Notes

The value returned by the hook can either be 'visible', 'hidden' and 'prerender'.

However the value 'prerender' is a non-standard feature and therefore browser support for this value is optional and might be poor.

Contributions

Contributions are welcome. File bug reports, create pull requests, feel free to reach out at tothab@gmail.com.

Licence

LGPL-3.0

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i react-hook-viewport-visibility

    Weekly Downloads

    0

    Version

    1.0.4

    License

    LGPL

    Unpacked Size

    10.6 kB

    Total Files

    5

    Last publish

    Collaborators

    • bence.a.toth