Skip to content

Commit

Permalink
2.6 Logout & 네비게이션
Browse files Browse the repository at this point in the history
  • Loading branch information
HyunAh-iia committed Jan 12, 2021
1 parent f9c6849 commit f459a0e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/components/Navigation.js
@@ -0,0 +1,15 @@
import React from "react";
import {Link} from "react-router-dom";

const Navigation = () => <nav>
<ul>
<li>
<Link to="/">홈으로</Link>
</li>
<li>
<Link to="/profile">프로필</Link>
</li>
</ul>
</nav>

export default Navigation;
13 changes: 11 additions & 2 deletions src/components/Router.js
@@ -1,18 +1,27 @@
import React, { useState } from 'react';
import {HashRouter as HRouter, Route, Switch} from 'react-router-dom';
import {HashRouter as HRouter, Route, Redirect, Switch} from 'react-router-dom';
import Auth from "routes/Auth";
import Home from "routes/Home";
import Profile from "routes/Profile";
import Navigation from "components/Navigation";

const Router = ({isLoggedIn}) => {

return (
<HRouter>
{isLoggedIn && <Navigation/>}
<Switch>
{isLoggedIn ?
<>
<Route exact path="/"><Home/></Route>
<Route exact path="/profile"><Profile/></Route>
<Redirect from="*" to="/" />
</> :
<Route exact path="/"><Auth /></Route>}
<>
<Route exact path="/"><Auth /></Route>
<Redirect from="*" to="/" />
</>
}
</Switch>
</HRouter>
);
Expand Down
14 changes: 12 additions & 2 deletions src/routes/Profile.js
@@ -1,6 +1,16 @@
import React from 'react';
import EditProfile from "routes/EditProfile";
import {authService} from "../myFirebase";

const Profile = () => {
const onLogout = () => authService.signOut();

return (
<>
<button onClick={onLogout}>로그아웃</button>
<span>Profile</span>
</>
);
};

const Profile = () => <span>Profile</span>;

export default Profile;

0 comments on commit f459a0e

Please sign in to comment.