-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApp.jsx
40 lines (32 loc) · 958 Bytes
/
App.jsx
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
40
import React from "react";
import { Redirect, Route, Switch } from "react-router-dom";
import { useDispatch } from "utils/react-redux-hooks";
import { setWidth } from "./redux/actions/news";
import Home from "./components/home/Home";
import LoginRegister from "./components/login-register/LoginRegister";
import "./App.css";
const App = () => {
const dispatch = useDispatch();
React.useEffect(() => {
window.addEventListener("resize", () => {
dispatch(setWidth(window.innerWidth));
});
return () => {
window.removeEventListener("resize", () => {
dispatch(setWidth(window.innerWidth));
});
};
}, [dispatch]);
return (
<div className="App">
<Switch>
<Route exact path="/">
<Redirect to="/home" />
</Route>
<Route path="/profile/" component={LoginRegister} />
<Route path="/" component={Home} />
</Switch>
</div>
);
};
export default App;