Closed soto0 closed 11 months ago
Feel free to check out the docs for the DatePickerInput. It has a working example.
I didn't find a solution in the documentation
Hey! Thanks for opening the issue. Can you provide a minimal repro which demonstrates the issue? Posting a snippet of your code in the issue is useful, but it's not usually straightforward to run. A repro will help us debug the issue faster. Please try to keep the repro as small as possible. The easiest way to provide a repro is on snack.expo.dev. If it's not possible to repro it on snack.expo.dev, then you can also provide the repro in a GitHub repository.
here I am trying to pass the initial value for the date
useEffect(() => {
if (item) {
setValue("date", dayjs(item.date) || undefined, { shouldValidate: false });
}
}, [item]);
<Controller
control={control}
name="date"
rules={{ required: true }}
render={({ field: { onChange, value } }) => (
<DatePickerInput
label="Дата"
value={value}
locale="ru"
mode="outlined"
inputMode="start"
withDateFormatInLabel={false}
onChange={onChange}
/>
)}
/>
My recommendation would be to get a simplistic example working such as the one in the docs. This would rule out the issue is with your setup in particular. I don't see anything inherently wrong with your code, but it's hard to tell without a reproducible example.
in the documentation, I see that they are passing undefined, but I don’t see that it shows how to pass any date
I updated the snack https://snack.expo.dev/@fitzwabs/react-native-paper-dates-input. It now defaults to todays date.
this worked for me, thanks!
How do I set the initial value for the DatePickerInput. When I try to do this, when I try to open a modal with a date picker, I get undefined is not a function?