question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

adjustDayPickerHeight not calculating predictably when setting numberOfMonths prop dynamically

See original GitHub issue

On our project, we’re using a grid system that optionally passes us a screenClass prop to tell us what breakpoint we’re currently in. We’re using that breakpoint to pass a numberOfMonths prop to the DayPickerRangeController to render either two months for desktop or one month for mobile.

When we’re doing this, our function initializes as sm, which initially passes numberOfMonths={1}. It’s changed to numberOfMonths={2} shortly after once window.innerWidth is captured and the method is run.

Setting it to 1 on initial load breaks adjustDayPickerHeight for a month either 2 or 3 greater than the current one. As it’s calculated based off of calendarMonthWeeks, which is only set on componentDidMount right now, that value becomes stale until it’s triggered again.

adjustmonthheightissues

Possible Fix

Adding a check to componentDidUpdate for a variation in numberOfMonths and then triggering setCalendarMonthWeeks again fixes the issue.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
LMulveycommented, Feb 22, 2021

Sounds like this was a misunderstanding on my part and for that, I apologize. Thanks for stepping in and clearing it up. Looks like #2095 was created by someone following this thread and has been rebased!

1reaction
ljharbcommented, Feb 19, 2021

All I wanted to ensure is that your new test passes, even if the other tests next to it don’t. You implied that you’d be able to get them all passing, so I asked if you’d mind doing that in a separate PR, but #1415 deletes existing tests and it wasn’t clear to me that it was the proper approach. After that it seems like neither of us revisited #1395. If you’re willing to rebase it, I can get it landed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

adjustDayPickerHeight not calculating predictably ... - GitHub
We're using that breakpoint to pass a numberOfMonths prop to the DayPickerRangeController to render either two months for desktop or one ...
Read more >
Passing props dynamically to dynamic component in VueJS
To pass props dynamically, you can add the v-bind directive to your dynamic component ... And when it isn't, no properties will be...
Read more >
Dynamic array formulas and spilled array behavior
Excel formulas that return a set of values, also known as an array, return these values to neighboring cells. This behavior is called...
Read more >
Dynamic behavior in Svelte: working with variables and props
In this article we'll be using variables and props to make our app dynamic, allowing us to add and delete to-dos, mark them...
Read more >
Create calculation properties - Knowledge Base - HubSpot
Calculation properties in HubSpot allow you to set up custom equations based on number properties. You can also automatically calculate the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found