Skip to content

Commit

Permalink
Merge pull request #162 from AppQuality/develop
Browse files Browse the repository at this point in the history
Refactor(ErrorMessage): accept additional props
  • Loading branch information
iacopolea authored Jan 17, 2024
2 parents a359651 + 6da1963 commit f7a4c5d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/stories/form/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
ErrorMessageProps,
FieldProps,
ErrorMessage as FormikErrorMessage,
Field as FormikField,
Expand All @@ -14,13 +13,11 @@ import Input from "./input/Input";
import { Radio } from "./radio/Radio";

export const ErrorMessageWrapper = ({
children,
}: {
children: React.ReactNode;
}) => (
<StyledErrorMessage>
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<StyledErrorMessage {...props}>
<ExclamationCircle className="error-message-icon" title="Error" size={16} />
{children}
{props.children}
</StyledErrorMessage>
);

Expand All @@ -41,9 +38,11 @@ const StyledErrorMessage = styled.div`
}
`;

export const ErrorMessage = ({ ...props }: ErrorMessageProps) => (
<FormikErrorMessage {...props}>
{(msg) => <ErrorMessageWrapper>{msg}</ErrorMessageWrapper>}
export const ErrorMessage = ({
...props
}: { name: string } & React.HTMLAttributes<HTMLDivElement>) => (
<FormikErrorMessage name={props.name}>
{(msg) => <ErrorMessageWrapper {...props}>{msg}</ErrorMessageWrapper>}
</FormikErrorMessage>
);

Expand Down

0 comments on commit f7a4c5d

Please sign in to comment.