fix: use invalid message in context instead of children prop
This commit is contained in:
parent
617b7be249
commit
67207d7daf
@ -157,12 +157,12 @@ const [formErrorVariant, resolveFormErrorVariantProps] = vcn({
|
|||||||
interface FormErrorProps
|
interface FormErrorProps
|
||||||
extends VariantProps<typeof formErrorVariant>,
|
extends VariantProps<typeof formErrorVariant>,
|
||||||
AsChild,
|
AsChild,
|
||||||
ComponentPropsWithoutRef<"span"> {}
|
Omit<ComponentPropsWithoutRef<"span">, "children"> {}
|
||||||
|
|
||||||
const FormError = forwardRef<HTMLSpanElement, FormErrorProps>((props, ref) => {
|
const FormError = forwardRef<HTMLSpanElement, FormErrorProps>((props, ref) => {
|
||||||
const [variantProps, otherPropsCompressed] =
|
const [variantProps, otherPropsCompressed] =
|
||||||
resolveFormErrorVariantProps(props);
|
resolveFormErrorVariantProps(props);
|
||||||
const { asChild, children, ...otherPropsExtracted } = otherPropsCompressed;
|
const { asChild, ...otherPropsExtracted } = otherPropsCompressed;
|
||||||
|
|
||||||
const item = useContext(FormItemContext);
|
const item = useContext(FormItemContext);
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ const FormError = forwardRef<HTMLSpanElement, FormErrorProps>((props, ref) => {
|
|||||||
className={formErrorVariant(variantProps)}
|
className={formErrorVariant(variantProps)}
|
||||||
{...otherPropsExtracted}
|
{...otherPropsExtracted}
|
||||||
>
|
>
|
||||||
{children}
|
{item.invalid}
|
||||||
</Comp>
|
</Comp>
|
||||||
) : null;
|
) : null;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user