Created
November 29, 2021 11:33
-
-
Save codewithbernard/2d36e339a9d7db8cbcb3e68ba51dd11b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useRef } from 'react'; | |
| const App = () => { | |
| const scollToRef = useRef(); | |
| return ( | |
| <div className="container"> | |
| <button onClick={() => scollToRef.current.scrollIntoView()}> | |
| Scroll | |
| </button> | |
| <div ref={scollToRef}>You scrolled to me</div> | |
| </div> | |
| ); | |
| }; | |
| export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment