@aaronhayes/react-scroll-hook 中文文档教程
React Scroll Hook
使用 React Scroll
Install
$ npm install --save @aaronhayes/react-scroll-hook
$ yarn add @aaronhayes/react-scroll-hook
Usage
import { Link, Element , Events, animateScroll as scroll, scrollSpy, scroller } from 'react-scroll'
import useScrollSpy from '@aaronhayes/react-scroll-hook';
const MyScrollWatchingComponent = () => {
const location = useScrollSpy();
console.log(location);
// Location will either be undefined or the current element scrolled to.
return (
<div>
<h1>
You are currently scrolled to: {location}
</h1>
</div>
)
}
See Also
React Scroll Hook
Hook for watching vertical scrolling location when using React Scroll
Install
$ npm install --save @aaronhayes/react-scroll-hook
$ yarn add @aaronhayes/react-scroll-hook
Usage
import { Link, Element , Events, animateScroll as scroll, scrollSpy, scroller } from 'react-scroll'
import useScrollSpy from '@aaronhayes/react-scroll-hook';
const MyScrollWatchingComponent = () => {
const location = useScrollSpy();
console.log(location);
// Location will either be undefined or the current element scrolled to.
return (
<div>
<h1>
You are currently scrolled to: {location}
</h1>
</div>
)
}