We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
FieldInputProps
about #606
FieldInputProps extends AnyObject cause keyof unexpected operation.
AnyObject
keyof
microsoft/TypeScript#35600
type KeyOfFieldInputProps = keyof FieldInputProps<string, HTMLInputElement>; // type KeyOfFieldInputProps = 'string' | 'number';
in my opinion, extending AnyObject is unnecessary, cuz the type definition must be exactly.
The text was updated successfully, but these errors were encountered:
FieldRenderProps
#441 (comment)
field shouldn't put props that not define in FieldInputProps, if we wanna pass props to down level component, we have to wrap a HOC or something else.
// DatePicker.tsx import React, { useCallback } from 'react'; import moment from 'moment'; import { useField, UseFieldConfig } from 'react-final-form'; import { DatePicker, Form } from 'antd'; import { FormItemProps } from 'antd/lib/form'; import { DatePickerProps } from 'antd/lib/date-picker/interface'; type FinalDatePickerWrapperType = { name: string; formProps?: FormItemProps; pickerProps?: Omit<DatePickerProps, 'onChange'>; children?: React.ReactNode; } & UseFieldConfig<number>; type TimeChangeFunc = NonNullable<DatePickerProps['onChange']>; const FinalDatePickerWrapper: React.FC<FinalDatePickerWrapperType> = ({ name, formProps, pickerProps, children, ...config }) => { const { input, meta } = useField<number, HTMLInputElement>(name, config); const handleTimeChange = useCallback<TimeChangeFunc>( m => input.onChange(m ? m.startOf('second').unix() : 0), [input], ); return ( <Form.Item help={meta.touched && !meta.active && meta.error} {...formProps}> <DatePicker {...pickerProps} onChange={handleTimeChange} onOpenChange={e => { if (e.valueOf()) { input.onFocus(); } else { input.onBlur(); } }} value={moment.unix(input.value)} /> </Form.Item> ); }; export default FinalDatePickerWrapper; // main.tsx import DatePicker from './DatePicker'; <DatePicker formProps={{}} pickerProps={{}}/>
Sorry, something went wrong.
No branches or pull requests
about #606
Description
FieldInputProps
extendsAnyObject
causekeyof
unexpected operation.microsoft/TypeScript#35600
example
in my opinion, extending
AnyObject
is unnecessary, cuz the type definition must be exactly.The text was updated successfully, but these errors were encountered: