Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function useSearch(): [string, (value: string) => void] {
const { setSearchInput, triggerSearch } = useActions();
const searchInput = useGlobalState(m => m.search.input);
const query = useDebounce(searchInput);
const cancel = useRef(undefined);
useEffect(() => {
cancel.current && cancel.current();
cancel.current = triggerSearch(query, false);
}, [query]);
return [searchInput, setSearchInput];
}