jannikbuschke / formik-antd

Simple declarative bindings for Ant Design and Formik.
https://codesandbox.io/s/github/jannikbuschke/formik-antd-example
MIT License
590 stars 81 forks source link

DatePicker format error without keepOffset #187

Open skykingit opened 3 years ago

skykingit commented 3 years ago

When i use the datetime ,i found the value is not the current local time so i see your github code ,i found you transfer date to ISOString by toISOString function, but i can set the props "keepOffset" to prevent the transfer when i set keepOffset true,it did't work so i see you node_modules source code ,you just delete the props "keepOffset" i am so angry, your code is different between github and node_module

....................................................... the github code is below : formik-antd/src/date-picker/index.tsx

export const DatePicker = ({ name, validate, onChange, fast, keepOffset, ...restProps }: DatePickerProps) => (

{({ field: { value }, form: { setFieldValue, setFieldTouched }, }: FieldProps) => ( <$DatePicker value={value ? moment(value) : undefined} onChange={(date, dateString) => { setFieldValue(name, date ? date.toISOString(keepOffset) : null) setFieldTouched(name, true, false) onChange && onChange(date, dateString) }} {...restProps} /> )}

)

export default DatePicker


the node_module code is

export const DatePicker = ({ name, validate, onChange, fast, ...restProps }: DatePickerProps) => (

{({ field: { value }, form: { setFieldValue, setFieldTouched }, }: FieldProps) => ( <$DatePicker value={value ? moment(value) : undefined} onChange={(date, dateString) => { setFieldValue(name, date ? date.toISOString() : null) setFieldTouched(name, true, false) onChange && onChange(date, dateString) }} {...restProps} /> )}

)

export default DatePicker

jannikbuschke commented 3 years ago

this repos master branch is probably ahead of the version you have installed.

Check https://www.npmjs.com/package/formik-antd for the latest version. 2.1.0-beta.5 might solve your problem