@cripty2001/utils 0.0.183 → 0.0.185
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-whispr.js +8 -4
- package/package.json +1 -1
package/dist/react-whispr.js
CHANGED
|
@@ -282,12 +282,9 @@ function getRelTimeFormat(_diff) {
|
|
|
282
282
|
*/
|
|
283
283
|
function useSearcher(data, limit) {
|
|
284
284
|
const searcher = (0, react_1.useRef)(new Searcher_1.Searcher(data));
|
|
285
|
-
(0, react_1.useEffect)(() => {
|
|
286
|
-
searcher.current.updateData(data);
|
|
287
|
-
}, [data]);
|
|
288
285
|
const [pending, setPending] = (0, react_1.useState)(false);
|
|
289
286
|
const [results, setResults] = (0, react_1.useState)({
|
|
290
|
-
results:
|
|
287
|
+
results: [],
|
|
291
288
|
_meta: {
|
|
292
289
|
ts: 0,
|
|
293
290
|
config: { q: "" }
|
|
@@ -298,6 +295,13 @@ function useSearcher(data, limit) {
|
|
|
298
295
|
results: searcher.current.search(q, limit)
|
|
299
296
|
};
|
|
300
297
|
}, setPending);
|
|
298
|
+
(0, react_1.useEffect)(() => {
|
|
299
|
+
searcher.current.updateData(data);
|
|
300
|
+
setResults(draft => {
|
|
301
|
+
draft.results = searcher.current.search(q.q, limit);
|
|
302
|
+
return draft;
|
|
303
|
+
});
|
|
304
|
+
}, [data, q, limit, setResults]);
|
|
301
305
|
return [
|
|
302
306
|
q.q,
|
|
303
307
|
(q) => setQ(draft => { draft.q = q; }),
|
package/package.json
CHANGED