You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-06 09:19:22 +02:00
18 lines
397 B
TypeScript
18 lines
397 B
TypeScript
import { useEffect } from 'react';
|
|
import CommandService from '@joplin/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]);
|
|
}
|