File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { useCallback } from 'react' ;
1+ import { useCallback , useMemo } from 'react' ;
22import type { OnyxCollection } from 'react-native-onyx' ;
33import ONYXKEYS from '@src/ONYXKEYS' ;
44import type { Transaction } from '@src/types/onyx' ;
55import useOnyx from './useOnyx' ;
66
77function useTransactionsByID ( transactionIDs : string [ ] | undefined ) {
8+ const transactionIDsKey = transactionIDs ?. join ( '|' ) ?? '' ;
9+ const stableTransactionIDs = useMemo ( ( ) => ( transactionIDsKey ? transactionIDsKey . split ( '|' ) : [ ] ) , [ transactionIDsKey ] ) ;
10+
811 const transactionsSelector = useCallback (
9- ( transactions : OnyxCollection < Transaction > ) => transactionIDs ? .map ( ( id ) => transactions ?. [ `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ id } ` ] ) ?? [ ] ,
10- [ transactionIDs ] ,
12+ ( transactions : OnyxCollection < Transaction > ) => stableTransactionIDs . map ( ( id ) => transactions ?. [ `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ id } ` ] ) ,
13+ [ stableTransactionIDs ] ,
1114 ) ;
1215
1316 const [ transactions ] = useOnyx (
You can’t perform that action at this time.
0 commit comments