Is there an elegant way of integrating dateinput with formik?
My code below works however it's tedious (not DRY :( ) to implement. It will require a state for every date input. I hope you don't mind sharing your code. Thanks
const ClaimsForm = () => {
const [value, setValue] = React.useState<Date | null>(new Date());
const changeDate = (event: DateInputChangeEvent) => {
setValue(event.value);
};
const initialValues = {
decisionDate: value
};
const handleSubmit = (values: any) => {
console.log(values)
}
return (
<Formik
initialValues={initialValues}
onSubmit={handleSubmit}
enableReinitialize={true}
>
{({ isSubmitting }) => (
<Form>
<DateInput name='decisionDate' value={value} onChange={changeDate} />
</Form>
)}
)
}