Skip to content

Commit

Permalink
fix(react): solve disappearing checked state in ChoiceField and Radio…
Browse files Browse the repository at this point in the history
…Group
  • Loading branch information
lucas-contreras committed Nov 15, 2023
1 parent 2fb56d1 commit adfa78c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/react/src/components/ChoiceField/Choice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classNames from 'classnames';
import { BaseInput } from '../BaseInput';
import { Icon } from '../Icon';
import { FieldInfo, FieldFeedback } from '../Field';
import { useForwardedRef, useId } from '../../utilities';
import { useForwardedRef, useId, useIsomorphicLayoutEffect } from '../../utilities';
import { ChoiceProps } from './types';

/**
Expand Down Expand Up @@ -68,7 +68,7 @@ export const Choice = React.forwardRef<HTMLInputElement, ChoiceProps>(({

// treat prop versions of internal state as source of truth
React.useEffect(() => setErrors(errorsProp), [errorsProp]);
React.useEffect(() => setChecked(checkedProp), [checkedProp]);
useIsomorphicLayoutEffect(() => setChecked(checkedProp), [checkedProp]);
React.useEffect(() => setIndeterminate(indeterminateProp), [indeterminateProp]);

const indicator = React.useMemo(() => {
Expand Down

0 comments on commit adfa78c

Please sign in to comment.