Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial date value #305

Closed
soto0 opened this issue Aug 9, 2023 · 8 comments
Closed

Initial date value #305

soto0 opened this issue Aug 9, 2023 · 8 comments
Labels
needs repro Needs reproducible example question Further information is requested

Comments

@soto0
Copy link

soto0 commented Aug 9, 2023

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?

@soto0 soto0 added the question Further information is requested label Aug 9, 2023
@iM-GeeKy
Copy link
Collaborator

iM-GeeKy commented Aug 9, 2023

Feel free to check out the docs for the DatePickerInput. It has a working example.

@soto0
Copy link
Author

soto0 commented Aug 9, 2023

I didn't find a solution in the documentation

@iM-GeeKy iM-GeeKy added the needs repro Needs reproducible example label Aug 9, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2023

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.

@soto0
Copy link
Author

soto0 commented Aug 9, 2023

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}
                            />
                        )}
                    />

@iM-GeeKy
Copy link
Collaborator

iM-GeeKy commented Aug 9, 2023

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.

@soto0
Copy link
Author

soto0 commented Aug 9, 2023

in the documentation, I see that they are passing undefined, but I don’t see that it shows how to pass any date

@iM-GeeKy
Copy link
Collaborator

iM-GeeKy commented Aug 9, 2023

I updated the snack https://snack.expo.dev/@fitzwabs/react-native-paper-dates-input. It now defaults to todays date.

@soto0
Copy link
Author

soto0 commented Aug 9, 2023

this worked for me, thanks!

@soto0 soto0 closed this as completed Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Needs reproducible example question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants