mirror of https://github.com/laurent22/joplin.git
18 lines
389 B
TypeScript
18 lines
389 B
TypeScript
import { useEffect } from 'react';
|
|
import CommandService from 'lib/services/CommandService';
|
|
const debounce = require('debounce');
|
|
|
|
export default function useSearch(query:string) {
|
|
useEffect(() => {
|
|
const search = debounce((query:string) => {
|
|
CommandService.instance().execute('search', query);
|
|
}, 500);
|
|
|
|
search(query);
|
|
|
|
return () => {
|
|
search.clear();
|
|
};
|
|
}, [query]);
|
|
}
|