File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 1- import { useEffect , useState } from 'react' ;
1+ import { useCallback , useEffect , useState } from 'react' ;
22
33import { Reactions } from '../types' ;
44import { fetcher } from '../fetcher' ;
@@ -32,6 +32,13 @@ 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+
3542 useEffect ( ( ) => {
3643 setHydrated ( true ) ;
3744 } , [ ] ) ;
@@ -176,12 +183,12 @@ export default function useArticleReactions(slug) {
176183 setReactionsToLocalStorage ( updatedReactionState ) ;
177184 }
178185
179- function getReactionsFromLocalStorage ( ) {
180- if ( typeof window !== 'undefined' ) {
181- return JSON . parse ( localStorage . getItem ( slug ) ) || initialReactionState ;
182- }
183- return null ;
184- }
186+ // function getReactionsFromLocalStorage() {
187+ // if (typeof window !== 'undefined') {
188+ // return JSON.parse(localStorage.getItem(slug)) || initialReactionState;
189+ // }
190+ // return null;
191+ // }
185192
186193 function setReactionsToLocalStorage ( reactions ) {
187194 if ( typeof window !== 'undefined' ) {
You can’t perform that action at this time.
0 commit comments