1import { useEffect } from 'react';
2import { withRouter } from 'react-router-dom';
3
4function ScrollToTop({ history }) {
5 useEffect(() => {
6 const unlisten = history.listen(() => {
7 window.scrollTo(0, 0);
8 });
9 return () => {
10 unlisten();
11 }
12 }, []);
13
14 return (null);
15}
16
17export default withRouter(ScrollToTop);
18