-
Notifications
You must be signed in to change notification settings - Fork 273
Expand file tree
/
Copy pathApp.js
More file actions
43 lines (36 loc) · 1.13 KB
/
App.js
File metadata and controls
43 lines (36 loc) · 1.13 KB
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
41
42
43
import './App.css';
import { Route, Routes } from "react-router-dom";
import Header from './componets/Header';
import React, { useEffect } from 'react';
import Login from './componets/Login';
import Blogs from './componets/Blogs';
import UserBlogs from './componets/UserBlogs'
import AddBlogs from './componets/AddBlogs'
import BlogDetail from './componets/BlogDetail'
import { useDispatch } from 'react-redux';
import { authActions } from './store';
function App() {
const dispatch = useDispatch();
useEffect(()=>{
const userId = localStorage.getItem("userId");
if(userId){
dispatch(authActions.login());
}
},[dispatch]);
return <React.Fragment>
<header>
<Header/>
</header>
<main>
<Routes>
<Route path="/" element={<Blogs />} />
<Route path="/login" element={<Login/>}></Route>
<Route path="/blogs" element={<Blogs/>}></Route>
<Route path="/myBlogs" element={<UserBlogs/>}></Route>
<Route path="/myBlogs/:id" element={<BlogDetail/>}></Route>
<Route path="/blogs/add" element={<AddBlogs />} />
</Routes>
</main>
</React.Fragment>;
}
export default App;