I don't use formik's Field
with react-native
because doc says <Field /> will default to an HTML <input /> element
I'd like to use useField
(https://stackoverflow.com/a/58650742/433570)
and wonder useField
is usable with react-native?
import React from "react";
import { useField, useFormikContext } from "formik";
import DatePicker from "react-datepicker";
export const DatePickerField = ({ ...props }) => {
const { setFieldValue } = useFormikContext();
const [field] = useField(props);
return (
<DatePicker
{...field}
{...props}
selected={(field.value && new Date(field.value)) || null}
onChange={val => {
setFieldValue(field.name, val);
}}
/>
);
};