Cannot reset date in Calendar component manually #1694
Unanswered
galimovkirill
asked this question in
PrimeReact
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello 🤝
I have this example code, where I need to reset calendar's date manually via its API (https://primereact.org/calendar/#api.Calendar.methods).
In this example I'm trying to call method
updateViewDate
, passingnull
inside it.But in fact, I'm getting the error while pressing the button:
If I try to check the source code from the link in call stack, I will see that the method
updateViewDate
callssetCurrentMonth(value.getMonth())
without checking for truthy ofvalue
(the same thing for year property).Note: the API of this method is documented, that it can accept
Nullable
(value: Nullable<Date | Date[]>
)My suggestion is to check
value
for truthy before trying to set month/year in this method.If I will have an approve of this bug and possible solution, I can try to make a pull request with it.
Sandbox: https://codesandbox.io/p/devbox/objective-lena-ypxjyy?file=%2Fsrc%2FApp.tsx%3A22%2C16
Beta Was this translation helpful? Give feedback.
All reactions