File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ const StyledButton = styled(Button)<{ starred: boolean }>`
36
36
const CaseStarButton : React . FC < { id : string } > = ( { id } ) => {
37
37
const { starredCases, starCase } = useStarredCases ( ) ;
38
38
const isDesktop = useIsDesktop ( ) ;
39
- const starred = useMemo ( ( ) => Boolean ( starredCases . get ( id ) ) , [ id , starredCases ] ) ;
39
+ const starred = useMemo ( ( ) => Boolean ( starredCases . has ( id ) ) , [ id , starredCases ] ) ;
40
40
const text = starred ? "Remove from favorite" : "Add to favorite" ;
41
41
return (
42
42
< Tooltip { ...{ text } } place = { isDesktop ? "top" : "bottom" } >
Original file line number Diff line number Diff line change @@ -3,16 +3,16 @@ import { useMemo } from "react";
3
3
import { useLocalStorage } from "./useLocalStorage" ;
4
4
5
5
const useStarredCases = ( ) => {
6
- const initialValue = new Map < string , boolean > ( ) ;
6
+ const initialValue = new Set < string > ( ) ;
7
7
8
8
const [ localStarredCases , setLocalStarredCases ] = useLocalStorage ( "starredCases" , Array . from ( initialValue ) ) ;
9
9
10
- const starredCases = useMemo ( ( ) => new Map < string , boolean > ( localStarredCases ) , [ localStarredCases ] ) ;
10
+ const starredCases = useMemo ( ( ) => new Set < string > ( localStarredCases ) , [ localStarredCases ] ) ;
11
11
const starredCaseIds = Array . from ( starredCases . keys ( ) ) ;
12
12
13
13
const starCase = ( id : string ) => {
14
- if ( starredCases . get ( id ) ) starredCases . delete ( id ) ;
15
- else starredCases . set ( id , true ) ;
14
+ if ( starredCases . has ( id ) ) starredCases . delete ( id ) ;
15
+ else starredCases . add ( id ) ;
16
16
17
17
setLocalStarredCases ( Array . from ( starredCases ) ) ;
18
18
} ;
You can’t perform that action at this time.
0 commit comments