Created
March 10, 2023 08:07
-
-
Save MariusBongarts/9902738c2ca670644d259c2fdfe1ff75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type HistoryItem = chrome.history.HistoryItem; | |
export const useChromeHistorySearch = ( | |
query: chrome.history.HistoryQuery | |
): HistoryItem[] => { | |
const [historyItems, setHistoryItems] = useState<HistoryItem[]>([]); | |
useEffect(() => { | |
chrome.history | |
.search(query) | |
.then((historyItems) => setHistoryItems(historyItems)) | |
.catch(() => setHistoryItems([])); | |
}, [query]); | |
return historyItems; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment