You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
517 B
20 lines
517 B
import useLocalStorage from "@core/hooks/useLocalStorage.ts";
|
|
import { useCallback } from "react";
|
|
|
|
export function usePinnedItems({ storageName }: { storageName: string }) {
|
|
const [pinnedItems, setPinnedItems] = useLocalStorage<string[]>(
|
|
storageName,
|
|
[],
|
|
);
|
|
|
|
const togglePinnedItem = useCallback((label: string) => {
|
|
setPinnedItems((prev) =>
|
|
prev.includes(label) ? prev.filter((g) => g !== label) : [...prev, label]
|
|
);
|
|
}, []);
|
|
|
|
return {
|
|
pinnedItems,
|
|
togglePinnedItem,
|
|
};
|
|
}
|
|
|