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 }>`
3636const CaseStarButton : React . FC < { id : string } > = ( { id } ) => {
3737 const { starredCases, starCase } = useStarredCases ( ) ;
3838 const isDesktop = useIsDesktop ( ) ;
39- const starred = useMemo ( ( ) => Boolean ( starredCases . get ( id ) ) , [ id , starredCases ] ) ;
39+ const starred = useMemo ( ( ) => Boolean ( starredCases . has ( id ) ) , [ id , starredCases ] ) ;
4040 const text = starred ? "Remove from favorite" : "Add to favorite" ;
4141 return (
4242 < Tooltip { ...{ text } } place = { isDesktop ? "top" : "bottom" } >
Original file line number Diff line number Diff line change @@ -3,16 +3,16 @@ import { useMemo } from "react";
33import { useLocalStorage } from "./useLocalStorage" ;
44
55const useStarredCases = ( ) => {
6- const initialValue = new Map < string , boolean > ( ) ;
6+ const initialValue = new Set < string > ( ) ;
77
88 const [ localStarredCases , setLocalStarredCases ] = useLocalStorage ( "starredCases" , Array . from ( initialValue ) ) ;
99
10- const starredCases = useMemo ( ( ) => new Map < string , boolean > ( localStarredCases ) , [ localStarredCases ] ) ;
10+ const starredCases = useMemo ( ( ) => new Set < string > ( localStarredCases ) , [ localStarredCases ] ) ;
1111 const starredCaseIds = Array . from ( starredCases . keys ( ) ) ;
1212
1313 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 ) ;
1616
1717 setLocalStarredCases ( Array . from ( starredCases ) ) ;
1818 } ;
You can’t perform that action at this time.
0 commit comments