How prevent DatePickerInput default of current date?
I'm trying to use DatePickerInput following the example here: https://github.com/web-ridge/react-native-paper-dates/blob/master/example/src/ReadMeExampleDatePickerInput.tsx
import * as React from 'react'
import { DatePickerInput } from '../../src/index'
export default function ReadMeExampleDatePickerInput() {
const [inputDate, setInputDate] = React.useState<Date | undefined>(undefined)
return (
<>
<DatePickerInput
locale="en"
label="Birthdate"
value={inputDate}
onChange={(d) => setInputDate(d)}
inputMode="start"
autoComplete="birthdate-full"
// mode="outlined" (see react-native-paper docs)
// other react native TextInput props
/>
</>
)
}
In my case, the input is wrapped with react-hook-form (https://react-hook-form.com/) for control/validation.
When inputDate is undefined, the input field shows the current date, which seems a bit odd? This isn't the real underlying value managed by react-hook-form, hence attempting to submit the form results in a validation error (expected, because the user has not actually entered/selected a date yet!)
Am I missing something? Is there a way to have the input field blank, or better still use the placeholder value supported by the underlying TextInput from react-native-paper? Currently, it is confusing to show the user a date on-screen that "isn't actually there".
Can you check if this is resolved in the next version which will be released later this evening?
The problem is still there.
This should now be fixed. It was resolved in this commit in the following PR. https://github.com/web-ridge/react-native-paper-dates/pull/229/commits/d4025bd065aa83a3468fca0369f1babefa5b2c2f