-
Notifications
You must be signed in to change notification settings - Fork 2
/
Temp
39 lines (31 loc) · 1021 Bytes
/
Temp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
const useScrollToTop = () => {
const { pathname } = useLocation();
useEffect(() => {
window.scrollTo(0, 0);
}, [pathname]);
};
export default useScrollToTop;
import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import Home from './pages/Home/Home';
import Login from './pages/Login/Login';
import SignUp from './pages/SignUp/SignUp';
import ComponentsPage from './pages/Components/Components';
import useScrollToTop from './hooks/useScrollToTop';
const App = () => {
useScrollToTop(); // Custom hook is used here
return (
<Router>
<Switch>
<Route exact path="/" component={Home} />
<Route path="/login" component={Login} />
<Route path="/signup" component={SignUp} />
<Route path="/components" component={ComponentsPage} />
{/* Add more routes as needed */}
</Switch>
</Router>
);
};
export default App;