Skip to content

Commit

Permalink
fix: add debounce to break infinite call loop
Browse files Browse the repository at this point in the history
  • Loading branch information
KenLSM committed Nov 5, 2024
1 parent 9f8e80d commit 945587e
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
VisuallyHidden,
VStack,
} from '@chakra-ui/react'
import { get } from 'lodash'
import { debounce, get } from 'lodash'
import simplur from 'simplur'

import { DATE_DISPLAY_FORMAT } from '~shared/constants/dates'
Expand Down Expand Up @@ -439,13 +439,15 @@ const ChildrenBody = ({
items={
MYINFO_ATTRIBUTE_MAP[subField].fieldOptions as string[]
}
onChange={(option) =>
// This is bad practice but we have no choice because our
// custom Select doesn't forward the event.
// FIXME: Fix types
// @ts-expect-error type inference issue
setValue(fieldPath, option, { shouldValidate: true })
}
onChange={debounce(
(option) =>
// This is bad practice but we have no choice because our
// custom Select doesn't forward the event.
// FIXME: Fix types
setValue(fieldPath, option, { shouldValidate: true }),
200,
{ leading: true },
)}
/>
<FormErrorMessage>
{childrenSubFieldError?.message}
Expand Down

0 comments on commit 945587e

Please sign in to comment.