mirror of
https://github.com/Steffo99/todocolors.git
synced 2024-11-25 17:54:18 +00:00
Add isStarred
callback to StarredProvider
This commit is contained in:
parent
e27ace8d13
commit
506a27e989
2 changed files with 6 additions and 1 deletions
|
@ -6,4 +6,5 @@ export interface StarredContextData {
|
|||
setStarred: Dispatch<SetStateAction<string[] | undefined>>
|
||||
addStarred: (key: string) => void,
|
||||
removeStarred: (key: string) => void,
|
||||
isStarred: (key: string) => boolean,
|
||||
}
|
||||
|
|
|
@ -32,8 +32,12 @@ export function StarredProvider({children}: {children: ReactNode}) {
|
|||
})
|
||||
}, [])
|
||||
|
||||
const isStarred = useCallback((value: string) => {
|
||||
return starred.indexOf(value) >= 0
|
||||
}, [starred])
|
||||
|
||||
return (
|
||||
<StarredContext.Provider value={{starred, setStarred, addStarred, removeStarred}}>
|
||||
<StarredContext.Provider value={{starred, setStarred, addStarred, removeStarred, isStarred}}>
|
||||
{children}
|
||||
</StarredContext.Provider>
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue