Skip to content

Commit

Permalink
hotfix(condo): DOMA-10759 was memoized returned objects from useObjec…
Browse files Browse the repository at this point in the history
…ts hook. Fixed infinity loop on page (#5546)
  • Loading branch information
Alllex202 authored Nov 26, 2024
1 parent b83db39 commit 3efc94c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/codegen/generate.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dayjs from 'dayjs'
import { DocumentNode } from 'graphql'
import get from 'lodash/get'
import isFunction from 'lodash/isFunction'
import { useCallback, useEffect, useState } from 'react'
import { useCallback, useEffect, useState, useMemo } from 'react'

import { getClientSideSenderInfo } from '@open-condo/codegen/utils/userId'
import { useMutation, useQuery } from '@open-condo/next/apollo'
Expand Down Expand Up @@ -359,7 +359,7 @@ export function generateReactHooks<
...(typeof options === 'object' && 'fetchPolicy' in options ? null : { fetchPolicy: 'no-cache' }),
})

const objs: GQLObject[] = (data && data.objs) ? data.objs.filter(nonNull) : []
const objs: GQLObject[] = useMemo(() => (data && data.objs) ? data.objs.filter(nonNull) : [], [data])
const count = (data && data.meta) ? data.meta.count : null
const typedRefetch: IRefetchType<GQLObject, QueryVariables> = refetch
const typedFetchMore: IFetchMoreType<GQLObject, QueryVariables> = fetchMore
Expand Down

0 comments on commit 3efc94c

Please sign in to comment.