mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-26 05:16:41 +07:00
added useMemos to get data hooks
This commit is contained in:
parent
1904153bba
commit
d9feff085a
11 changed files with 49 additions and 19 deletions
|
@ -1,4 +1,4 @@
|
|||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
import { flatten } from 'ramda';
|
||||
import { getSearchResults } from '~/api/flow';
|
||||
|
@ -44,7 +44,7 @@ export const useSearch = () => {
|
|||
const loadMore = useCallback(() => setSize(size + 1), [setSize, size]);
|
||||
const hasMore = (data?.[size - 1]?.length || 0) >= RESULTS_COUNT;
|
||||
|
||||
const results = flatten(data || []);
|
||||
const results = useMemo(() => flatten(data || []), [data]);
|
||||
|
||||
useEffect(() => {
|
||||
const timeout = setTimeout(async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue