mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56: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
|
@ -3,7 +3,7 @@ import { GetLabNodesRequest, ILabNode } from '~/types/lab';
|
|||
import { getLabNodes } from '~/api/lab';
|
||||
import { flatten, last, uniqBy } from 'ramda';
|
||||
import { useLabStore } from '~/store/lab/useLabStore';
|
||||
import { useCallback } from 'react';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { INode } from '~/types';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
|
||||
|
@ -47,7 +47,7 @@ export const useGetLabNodes = () => {
|
|||
}
|
||||
);
|
||||
|
||||
const nodes = uniqBy(n => n.node.id, flatten(data || []));
|
||||
const nodes = useMemo(() => uniqBy(n => n.node.id, flatten(data || [])), [data]);
|
||||
const hasMore = (data?.[size - 1]?.length || 0) >= 1;
|
||||
const loadMore = useCallback(() => setSize(size + 1), [setSize, size]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue