Skip to content

Commit f23a512

Browse files
committed
refactor(Components): ♻️ Make the items prop optional.
Move the `rest` props to the wrapped `TextInputField` component inside the `Autocomplete component Assert the type for the returned object from the `useFieldApi` hook.
1 parent 6565c66 commit f23a512

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/evergreen-component-mapper/src/text-field/text-field.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import { UseFieldApiProps } from '@data-driven-forms/react-form-renderer';
77

88
export interface TextFieldProps extends UseFieldApiProps<string> {
99
name: string;
10-
items: string[];
10+
items?: string[];
1111
isRequired?: boolean;
1212
}
1313

1414
const TextField: React.FC<TextFieldProps> = (props) => {
15-
const { input, meta, isRequired, items, ...rest } = useFieldApi(props);
15+
const { input, meta, isRequired, items, ...rest } = useFieldApi(props) as TextFieldProps;
1616

1717
return (
18-
<Autocomplete {...input} items={items} {...rest}>
18+
<Autocomplete {...input} items={items || []}>
1919
{({ getInputProps, getRef, inputValue, openMenu }) => (
2020
<TextInputField
2121
ref={getRef}
@@ -24,6 +24,7 @@ const TextField: React.FC<TextFieldProps> = (props) => {
2424
validationMessage={meta.error}
2525
{...getInputProps({ onFocus: () => openMenu() })}
2626
value={inputValue}
27+
{...rest}
2728
/>
2829
)}
2930
</Autocomplete>

0 commit comments

Comments
 (0)