Skip to content

Commit 182aaf1

Browse files
Fix loadNotifications and Google Analytics Init (useEffect)
1 parent 2430571 commit 182aaf1

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

src/shared/components/Header/index.jsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,18 @@ const Header = ({
5454
}, []);
5555

5656
/*
57-
* Reload notificaitons if token was changed
58-
* This prevent to use expired token in API call
59-
*/
60-
if (auth) {
61-
useEffect(() => {
62-
loadNotifications(auth.tokenV3);
63-
}, [auth.tokenV3]);
64-
}
65-
66-
/*
67-
* Init Google Analytics
57+
* Load Notifications and Init Google Analytics
6858
*/
69-
if (auth && auth.user) {
70-
useEffect(() => {
71-
tracking.init(auth.user.handle);
72-
}, [auth.user.handle]);
73-
}
59+
useEffect(() => {
60+
if (auth) {
61+
if (auth.tokenV3) {
62+
loadNotifications(auth.tokenV3);
63+
}
64+
if (auth.user) {
65+
tracking.init(auth.user.handle);
66+
}
67+
}
68+
}, []);
7469

7570
if (TopNavRef) {
7671
return (

0 commit comments

Comments
 (0)