use-smooth-scroll
React hook to smooth scroll to an element in the web page
Install
npm install --save @getapper/use-smooth-scroll
Usage
import * as React from 'react'
import useSmoothScroll from '@getapper/use-smooth-scroll'
const Example = () => {
const divRef = useRef(null);
const cb = useSmoothScroll(divRef);
return (
<div>
<div>
<button onClick={cb}>
Scroll
</button>
</div>
<div ref={divRef}></div>
</div>
)
}
License
MIT © getapper
This hook is created using create-react-hook.