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

Error using time select #4765

Open
UnknownVladyslav opened this issue May 4, 2024 · 6 comments
Open

Error using time select #4765

UnknownVladyslav opened this issue May 4, 2024 · 6 comments

Comments

@UnknownVladyslav
Copy link

UnknownVladyslav commented May 4, 2024

Hi! I'm using react-datepicker on two projects. Both projects have same 4.8.0 version of library, but in the first i faced with a problem. I need to use showTimeSelect prop and when i select date (or select time firstly and then click on filled field), app crashes with an error as on screenshot. I use react-datepicker with react-hook-form's useController, i try to use almost identical datepicker components, but in one project i still have an error. I convert received value to timestamp and provide it to controller in the both components. Please, write if you need to be provided with more data or description, i`ll send it!

image

@UnknownVladyslav UnknownVladyslav closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2024
@mirus-ua
Copy link
Contributor

mirus-ua commented May 4, 2024

Hello
Most likely your date is undefined or null here

const startOfDay = new Date(d.getFullYear(), d.getMonth(), d.getDate());

@UnknownVladyslav
Copy link
Author

Thank a lot for reply!
I looked that this function gets selected prop to work with. I understand that it can drop an error because of providing timestamp value to component. But i tried to provide hardcoded timestamp value to similar components on screenshots with the similar other props and here we have two different results. First picture made in project where component drops an error just by clicking the input with hardcoded value, in the second case we can normally operate with the datepicker without errors (of course we have hardcoded value too, but we have controller value changing). So it looks weird for me now why we have different result using the same value for selected prop. On the third picture is the example of calendar working in the second project. But if i just clicking on prefilled input on the last screenshot - it crashes :(

image
image
image
image

@mirus-ua
Copy link
Contributor

mirus-ua commented May 5, 2024

try to isolate the selected prop from the rest of the optional props because one of them may affect business logic.
also, try to reproduce the problem on the latest version of the library -- 6.9.0

@UnknownVladyslav
Copy link
Author

I'm sorry, i forgot to write that update to 6.9.0 version didn't solve the problem. I played with props, only prop showTimeSelect affects on error. I used calendar in the second project without time selection, but i added it to check how would it work and it works ok. In the first project i have no error without showTImeSelect property.

@mirus-ua
Copy link
Contributor

mirus-ua commented May 5, 2024

I have more concerns about {...rest} spread

the library will be converted to TS soon #4700 so it might help with debugging your problem

@UnknownVladyslav
Copy link
Author

Rest is just empty object, i tried to remove influence of unnecessary props on component.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants