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

Cannot render calendar with only one week of data #18

Closed
nc-simv opened this issue May 23, 2022 · 3 comments
Closed

Cannot render calendar with only one week of data #18

nc-simv opened this issue May 23, 2022 · 3 comments

Comments

@nc-simv
Copy link

nc-simv commented May 23, 2022

If there is only one week of data there I get a

TypeError: Cannot read properties of undefined (reading 'map')

on https://github.com/grubersjoe/react-activity-calendar/blob/main/src/component/ActivityCalendar.tsx#L187

The reason seems to be that the groupByWeeks logic pads to one week but we try to access index 1 in the week array which may not be present. It is not clear to me if this could be fixed by accessing index 0 instead of one, or if groupByWeeks should add an extra week if there is only data for one week.

@nc-simv nc-simv changed the title Cannot render calendar with o Cannot render calendar with only one week of data May 23, 2022
@grubersjoe
Copy link
Owner

grubersjoe commented May 23, 2022

Hey. Thanks for reporting this. I was able to simplify the weekday label function, now it works for any amount of data. See this commit. Parsing the date to get the day index seems a bit silly when the week days array is left padded anyway.

Fixed in react-activity-calendar@1.5.1.

@grubersjoe
Copy link
Owner

Closing this, feel free to reopen if there's still an issue.

@nc-simv
Copy link
Author

nc-simv commented May 23, 2022

It works. Thank you so much for the quick response. Great work on the calendar I have enjoyed using it.

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