Skip to content

Commit

Permalink
fix unsafe assignment in forms
Browse files Browse the repository at this point in the history
  • Loading branch information
esizer committed Oct 2, 2024
1 parent b15769b commit 2d9c5a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/forms/src/components/SwitchInput/SwitchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const SwitchInput = forwardRef<ElementRef<typeof Switch>, SwitchInputProps>(
setValue,
watch,
formState: { errors, defaultValues },
} = useFormContext();
} = useFormContext<Record<string, boolean>>();
const value = watch(name);
const defaultValue = Boolean(defaultValues?.[name]);
const [descriptionIds, ariaDescribedBy] = useInputDescribedBy({
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/src/hooks/useFieldState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { FieldState } from "../types";
const useFieldState = (name: string, ignoreUnsaved = false): FieldState => {
const { errors, dirtyFields } = useFormState();
const isDirty = Boolean(get(dirtyFields, name, false));
const isInvalid = get(errors, name, false);
const isInvalid = get(errors, name, false) as boolean;

if (isInvalid) {
return "invalid";
Expand Down

0 comments on commit 2d9c5a2

Please sign in to comment.