Skip to content

Commit 83d0bf5

Browse files
committed
Fixed reaction style issue
1 parent 9b55441 commit 83d0bf5

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

lib/hooks/useArticleReactions.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useEffect, useState } from 'react';
1+
import { useEffect, useState } from 'react';
22

33
import { Reactions } from '../types';
44
import { fetcher } from '../fetcher';
@@ -32,13 +32,6 @@ export default function useArticleReactions(slug) {
3232
}
3333
);
3434

35-
const getReactionsFromLocalStorage = useCallback(() => {
36-
if (typeof window !== 'undefined') {
37-
return JSON.parse(localStorage.getItem(slug)) || initialReactionState;
38-
}
39-
return null;
40-
}, [slug]);
41-
4235
useEffect(() => {
4336
setHydrated(true);
4437
}, []);
@@ -55,7 +48,7 @@ export default function useArticleReactions(slug) {
5548
setHasClapped(clapped);
5649
setHasPartied(partied);
5750
}
58-
}, [getReactionsFromLocalStorage, hydrated]);
51+
}, [hydrated, setReactionsToLocalStorage]);
5952

6053
useEffect(() => {
6154
setReactions(data);
@@ -183,12 +176,12 @@ export default function useArticleReactions(slug) {
183176
setReactionsToLocalStorage(updatedReactionState);
184177
}
185178

186-
// function getReactionsFromLocalStorage() {
187-
// if (typeof window !== 'undefined') {
188-
// return JSON.parse(localStorage.getItem(slug)) || initialReactionState;
189-
// }
190-
// return null;
191-
// }
179+
function getReactionsFromLocalStorage() {
180+
if (typeof window !== 'undefined') {
181+
return JSON.parse(localStorage.getItem(slug)) || initialReactionState;
182+
}
183+
return null;
184+
}
192185

193186
function setReactionsToLocalStorage(reactions) {
194187
if (typeof window !== 'undefined') {

0 commit comments

Comments
 (0)