How to determine what is the currently viewed month
- Dominant language
- JavaScript
- Stars
- 2k
- Forks
- 858
- PR merge metrics
- No merged PRs in 30d
Description
I need to augment the date picker with certain events (like public holidays should be green etc.) and render these on the days view. I'm struggling to find out the current month and year rendered in the view. Same date that is on the navigation bar as `November 2021`
I tried certain things:
- `onNavigateBack` and `onNavigateForward` is not perfect as we have custom buttons allowing to set current date to e.g. "yesterday" which navigates the view to the current month
- `onChange` is worthless as at that point it is too late
- Hover events also doesn't do justice as while navigating you might not hover over any day cells.
The only workaround I found is highjacking `renderDay` callback and saving the dates it renders. However that is an anti-pattern as it updates the component state before it finishes its render. Even React is complaining about it `"Cannot update a component ("SomeComponent") while rendering a different component"`
I'm using v2 but that shouldn't matter as looking into v3 docs there is still nothing that can help achieve my goal.
Contributor guide
Research direction
Start by tracing the calendar navigation and the header value shown in the rdtSwitch element, then compare when onNavigateBack, onNavigateForward, onChange, and renderDay run. Done means the component provides a reliable way to identify the currently viewed month and year before day rendering, without updating state during render.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100