Skip to content

Commit

Permalink
fix: use invalid message in context instead of children prop
Browse files Browse the repository at this point in the history
  • Loading branch information
p-sw committed Aug 4, 2024
1 parent 617b7be commit 67207d7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ const [formErrorVariant, resolveFormErrorVariantProps] = vcn({
interface FormErrorProps
extends VariantProps<typeof formErrorVariant>,
AsChild,
ComponentPropsWithoutRef<"span"> {}
Omit<ComponentPropsWithoutRef<"span">, "children"> {}

const FormError = forwardRef<HTMLSpanElement, FormErrorProps>((props, ref) => {
const [variantProps, otherPropsCompressed] =
resolveFormErrorVariantProps(props);
const { asChild, children, ...otherPropsExtracted } = otherPropsCompressed;
const { asChild, ...otherPropsExtracted } = otherPropsCompressed;

const item = useContext(FormItemContext);

Expand All @@ -174,7 +174,7 @@ const FormError = forwardRef<HTMLSpanElement, FormErrorProps>((props, ref) => {
className={formErrorVariant(variantProps)}
{...otherPropsExtracted}
>
{children}
{item.invalid}
</Comp>
) : null;
});
Expand Down

0 comments on commit 67207d7

Please sign in to comment.