Skip to content

Commit f7e837a

Browse files
committed
(refactor) - move logout to useCB
1 parent eac37c6 commit f7e837a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/components/Header.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { getToken, deleteToken } from '../utils';
55

66
const Header = ({ history }) => {
77
const authToken = getToken();
8+
const logout = React.useCallback(() => {
9+
deleteToken();
10+
history.push('/');
11+
}, [history])
812
return (
913
<div className="flex pa1 justify-between nowrap orange">
1014
<div className="flex flex-fixed black">
@@ -33,10 +37,7 @@ const Header = ({ history }) => {
3337
{authToken ? (
3438
<div
3539
className="ml1 pointer black"
36-
onClick={() => {
37-
deleteToken();
38-
history.push('/');
39-
}}
40+
onClick={logout}
4041
>
4142
logout
4243
</div>

0 commit comments

Comments
 (0)