type TextFieldProps = {
label: string
placeholder?: string
} & Omit<TextInputProps, 'label' | 'value' | 'onChange' | 'error' | 'name'>
export const TextField = ({ label, placeholder, ...props }: TextFieldProps) => {
// The `Field` infers that it should have a `value` type of `string`
const field = useFieldContext<string | number>()
return (
<TextInput
label={label}
placeholder={placeholder || ''}
name={field.name}
value={field.state.value}
onChange={(e) => field.handleChange(e.target.value)}
error={!field.state.meta.isValid && field.state.meta.errors.join(', ')}
{...props}
/>
)
}
type TextFieldProps = {
label: string
placeholder?: string
} & Omit<TextInputProps, 'label' | 'value' | 'onChange' | 'error' | 'name'>
export const TextField = ({ label, placeholder, ...props }: TextFieldProps) => {
// The `Field` infers that it should have a `value` type of `string`
const field = useFieldContext<string | number>()
return (
<TextInput
label={label}
placeholder={placeholder || ''}
name={field.name}
value={field.state.value}
onChange={(e) => field.handleChange(e.target.value)}
error={!field.state.meta.isValid && field.state.meta.errors.join(', ')}
{...props}
/>
)
}