Skip to content

Commit

Permalink
fix: hook infinite loop call
Browse files Browse the repository at this point in the history
  • Loading branch information
DinizSa committed Nov 20, 2024
1 parent 66f0fe6 commit a49cac6
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react'
import { BuilderStatusFilter } from '@/app/collective-rewards/whitelist'
import { BuilderProposal, useBuilderContext } from '@/app/collective-rewards/user'
import { BuilderStateDetails } from '@/app/collective-rewards/types'
import { useBuilderContext } from '@/app/collective-rewards/user'
import { BuilderStatusFilter } from '@/app/collective-rewards/whitelist'
import { useMemo } from 'react'

type FetchWhitelistedBuildersFilter = {
builderName: string
Expand All @@ -16,10 +16,9 @@ export const useGetFilteredBuilders = ({
status: filterStatus,
stateFlags,
}: FetchWhitelistedBuildersFilter) => {
const [data, setData] = useState<BuilderProposal[]>([])
const { data: builders, isLoading, error } = useBuilderContext()

useEffect(() => {
const data = useMemo(() => {
let filteredBuilders = builders

if (filterBuilderName) {
Expand All @@ -42,8 +41,7 @@ export const useGetFilteredBuilders = ({
if (filterStatus !== 'all') {
filteredBuilders = filteredBuilders.filter(builder => builder.status === filterStatus)
}

setData(filteredBuilders)
return filteredBuilders
}, [builders, filterBuilderName, filterStatus, stateFlags])

return {
Expand Down

0 comments on commit a49cac6

Please sign in to comment.