diff --git a/src/ErrorMessage.test.tsx b/src/ErrorMessage.test.tsx
index cbe9c8c..4c8636b 100644
--- a/src/ErrorMessage.test.tsx
+++ b/src/ErrorMessage.test.tsx
@@ -45,7 +45,7 @@ describe('ErrorMessage', () => {
expect(asFragment()).toMatchSnapshot();
});
- it('should render correctly with flat errors and as with component and render', () => {
+ it('should render correctly with flat errors and as with element and render', () => {
const { asFragment } = render(
}
@@ -58,7 +58,7 @@ describe('ErrorMessage', () => {
expect(asFragment()).toMatchSnapshot();
});
- it('should render correctly with flat errors and as with component and className and render', () => {
+ it('should render correctly with flat errors and as with element and className and render', () => {
const { asFragment } = render(
}
@@ -72,6 +72,37 @@ describe('ErrorMessage', () => {
expect(asFragment()).toMatchSnapshot();
});
+ it('should render correctly with flat errors and as with component', () => {
+ function CustErrComp({ children }: { children: React.ReactNode }) {
+ return
{children}
;
+ }
+ const { asFragment } = render(
+ ,
+ );
+
+ expect(asFragment()).toMatchSnapshot();
+ });
+
+ it('should render correctly with flat errors and as with component and render', () => {
+ function CustErrComp({ children }: { children: React.ReactNode }) {
+ return {children}
;
+ }
+ const { asFragment } = render(
+ message}
+ />,
+ );
+
+ expect(asFragment()).toMatchSnapshot();
+ });
+
it('should render correctly with flat multiple errors and render', () => {
const { asFragment } = render(
{
expect(asFragment()).toMatchSnapshot();
});
- it('should render correctly with flat multiple errors and as with component and render', () => {
+ it('should render correctly with flat multiple errors and as with element and render', () => {
const { asFragment } = render(
}
@@ -204,7 +235,7 @@ describe('ErrorMessage', () => {
expect(asFragment()).toMatchSnapshot();
});
- it('should render correctly with nested multiple errors and as with component and render', () => {
+ it('should render correctly with nested multiple errors and as with element and render', () => {
const { asFragment } = render(
}
@@ -269,7 +300,7 @@ describe('ErrorMessage', () => {
expect(asFragment()).toMatchSnapshot();
});
- it('should render correctly with nested errors array and as with component and render', () => {
+ it('should render correctly with nested errors array and as with element and render', () => {
const { asFragment } = render(
}
@@ -319,7 +350,7 @@ describe('ErrorMessage', () => {
expect(asFragment()).toMatchSnapshot();
});
- it('should render correctly with nested multiple errors array and as with component and render', () => {
+ it('should render correctly with nested multiple errors array and as with element and render', () => {
const { asFragment } = render(
}
diff --git a/src/__snapshots__/ErrorMessage.test.tsx.snap b/src/__snapshots__/ErrorMessage.test.tsx.snap
index 1eee977..f9fc891 100644
--- a/src/__snapshots__/ErrorMessage.test.tsx.snap
+++ b/src/__snapshots__/ErrorMessage.test.tsx.snap
@@ -8,7 +8,21 @@ exports[`ErrorMessage should render correctly with flat errors 1`] = `
`;
-exports[`ErrorMessage should render correctly with flat errors and as with component and className and render 1`] = `
+exports[`ErrorMessage should render correctly with flat errors and as with component 1`] = `
+
+
+ flat
+
+
+`;
+
+exports[`ErrorMessage should render correctly with flat errors and as with component and render 1`] = `
+
+ flat
+
+`;
+
+exports[`ErrorMessage should render correctly with flat errors and as with element and className and render 1`] = `
`;
-exports[`ErrorMessage should render correctly with flat errors and as with component and render 1`] = `
+exports[`ErrorMessage should render correctly with flat errors and as with element and render 1`] = `
flat
@@ -44,7 +58,7 @@ exports[`ErrorMessage should render correctly with flat errors and as with strin
`;
-exports[`ErrorMessage should render correctly with flat multiple errors and as with component and render 1`] = `
+exports[`ErrorMessage should render correctly with flat multiple errors and as with element and render 1`] = `
flat
@@ -86,7 +100,7 @@ exports[`ErrorMessage should render correctly with nested errors array 1`] = `
`;
-exports[`ErrorMessage should render correctly with nested errors array and as with component and render 1`] = `
+exports[`ErrorMessage should render correctly with nested errors array and as with element and render 1`] = `
array
@@ -116,7 +130,7 @@ exports[`ErrorMessage should render correctly with nested errors object and as w
`;
-exports[`ErrorMessage should render correctly with nested multiple errors and as with component and render 1`] = `
+exports[`ErrorMessage should render correctly with nested multiple errors and as with element and render 1`] = `
object
@@ -138,7 +152,7 @@ exports[`ErrorMessage should render correctly with nested multiple errors and re
`;
-exports[`ErrorMessage should render correctly with nested multiple errors array and as with component and render 1`] = `
+exports[`ErrorMessage should render correctly with nested multiple errors array and as with element and render 1`] = `
array
diff --git a/src/types.ts b/src/types.ts
index 4f57c08..5a4426a 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -17,7 +17,7 @@ type AsProps
= TAs extends undefined
: TAs extends React.ReactElement
? Record
: TAs extends React.ComponentType
- ? P
+ ? Omit
: TAs extends keyof JSX.IntrinsicElements
? JSX.IntrinsicElements[TAs]
: never;