Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@react-hooks-custom/use-scroll

littleee55MIT1.1.1TypeScript support: included

Get scrolling value quickly by React hook

react, react hook, hook, react hooks, hooks, window scroll, window scroll hook, scroll position, viewport, viewport scroll, viewport scroll hook, usewindowscroll, use window scroll, react window scroll hook, react scroll position hook, usescrollposition, use scroll position, scroll position hook

readme


useScroll()

Bundlephobia Types NPM Version

npm i @react-hooks-custom/use-scroll

A React hook for updating components when the scroll position of the window on the y-axis changes.

Quick Start

import useScroll from '@react-hooks-custom/use-scroll'

const Component = (props) => {
  const { scrollX, scrollY } = useScroll();

  return <div>scroll pos: {scrollX}, {scrollY}</div>
}

API

useScroll () => ScrollType

type ScrollType = {
  scrollX: number;
  scrollY: number;
}

Returns { scrollX, scrollY }

|| Type | Description ---|---|--- scrollX | number | The current scroll position of the window on the x-axis scrollY | number | The current scroll position of the window on the y-axis

LICENSE

MIT

changelog

@react-hooks-custom/use-scroll ChangeLog

1.0.0

  • Initial release