Download Portfolio/src/components/ScrollToTop.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 258 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/Portfolio/src/components/ScrollToTop.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/Portfolio/src/components/ScrollToTop.js
-
curl -L -o ScrollToTop.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/Portfolio/src/components/ScrollToTop.js
258 Bytes
| import { useEffect } from "react"; | |
| import { useLocation } from "react-router-dom"; | |
| function ScrollToTop() { | |
| const { pathname } = useLocation(); | |
| useEffect(() => { | |
| window.scrollTo(0, 0); | |
| }, [pathname]); | |
| return null; | |
| } | |
| export default ScrollToTop; | |