Skip to content

Commit 643b139

Browse files
authored
Memoize data in use-data-object-grids.ts (#3629)
1 parent 49a8d7e commit 643b139

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • assets/js/src/core/modules/element/dynamic-types/definitions/objects/data-related/components/many-to-many-object-relation/hooks

assets/js/src/core/modules/element/dynamic-types/definitions/objects/data-related/components/many-to-many-object-relation/hooks/use-data-object-grids.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @license Pimcore Open Core License (POCL)
99
*/
1010

11+
import { useMemo } from 'react'
1112
import { map, filter, isEmpty } from 'lodash'
1213
import {
1314
type DataObjectGetGridApiResponse,
@@ -64,7 +65,7 @@ export const useDataObjectGrids = ({ classIds, convertClassName, columns, applyF
6465
})
6566

6667
const isLoading = queries.some(q => q.isLoading || q.isFetching)
67-
const data = queries.flatMap(q => q.data?.items ?? [])
68+
const data = useMemo(() => queries.flatMap(q => q.data?.items ?? []), queries.map(q => q.data))
6869
const refetchAll = (): void => { queries.forEach(q => { void q.refetch() }) }
6970

7071
return { isLoading, data, refetchAll }

0 commit comments

Comments
 (0)