@cripty2001/utils 0.0.182 → 0.0.184

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.
@@ -281,6 +281,7 @@ function getRelTimeFormat(_diff) {
281
281
  * - A boolean indicating if the search is pending
282
282
  */
283
283
  function useSearcher(data, limit) {
284
+ const searcher = (0, react_1.useRef)(new Searcher_1.Searcher(data));
284
285
  const [pending, setPending] = (0, react_1.useState)(false);
285
286
  const [results, setResults] = (0, react_1.useState)({
286
287
  results: [],
@@ -289,16 +290,15 @@ function useSearcher(data, limit) {
289
290
  config: { q: "" }
290
291
  }
291
292
  });
292
- const searcher = (0, react_1.useRef)(new Searcher_1.Searcher(data));
293
- (0, react_1.useEffect)(() => {
294
- searcher.current.updateData(data);
295
- }, [data]);
296
293
  const [q, setQ] = useAsyncInput(results, setResults, async ({ q }) => {
297
294
  return {
298
295
  results: searcher.current.search(q, limit)
299
296
  };
300
297
  }, setPending);
301
- setQ(draft => { draft.q = ""; }); // Running the first search with the empty query
298
+ (0, react_1.useEffect)(() => {
299
+ searcher.current.updateData(data);
300
+ setQ(draft => { draft.q = ""; });
301
+ }, [data, setQ]);
302
302
  return [
303
303
  q.q,
304
304
  (q) => setQ(draft => { draft.q = q; }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.182",
3
+ "version": "0.0.184",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {