Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ declare function ArrayField({
}: {
children: (arrayFieldApi: ArrayFieldApi & ArrayFieldState) => JSX.Element;
name: string;
initialValue?: [unknown];
initialValue?: unknown[];
arrayFieldApiRef?: React.MutableRefObject<any>;
}): JSX.Element;

Expand Down
22 changes: 19 additions & 3 deletions index.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ import {
FormProvider,
} from '.';

import {expectType} from 'tsd';
import { expectError, expectType } from 'tsd';

expectError(
<ArrayField name="friendsInvalid" initialValue={{ name: 'Nope' }}>
{() => <></>}
</ArrayField>
);


type FormProps = React.FormHTMLAttributes<HTMLFormElement>;
Expand Down Expand Up @@ -357,7 +363,13 @@ const ComponentUsingOtherShit = () => {
}
</FormStateAccessor>
{/* ---------- Array Field ---------- */}
<ArrayField name="friends" initialValue={[{ name: 'Joe', age: 29}]} arrayFieldApiRef={arrayFieldApiRef}>
<ArrayField
name="friends"
initialValue={[
{ name: 'Joe', age: 29 },
{ name: 'Sue', age: 31 }
]}
arrayFieldApiRef={arrayFieldApiRef}>
{({ add }) => {
return (
<>
Expand All @@ -384,6 +396,10 @@ const ComponentUsingOtherShit = () => {
);
}}
</ArrayField>
<ArrayField name="friendsSingle" initialValue={[{ name: 'Solo', age: 45 }]}>
{() => <></>}
</ArrayField>
<ArrayField name="friendsNoInitial">{() => <></>}</ArrayField>
</>
);
};
Expand Down Expand Up @@ -433,4 +449,4 @@ export const ProviderTest = () => {
</FormProvider>
</Informed>
);
}
}