Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor(ErrorMessage): accept additional props #162

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading