How to determine what is the currently viewed month

Open
#810 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
28/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript, react
Domain
frontend

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.

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 <th class="rdtSwitch">November 2021</th>

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.

Dominant language
JavaScript
Stars
2k
Forks
858
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from arqex/react-datetime

All issues in arqex/react-datetime

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.