I am rendering a calendar component, which is again rendering a Month
component based on a months
array:
{
months.map(month =>
<div style={{marginBottom: "35px"}} key={month}>
<Month
monthName={this.renderMonthName(month)}
daysOfMonth={Object.keys(calendarDays).filter(day => new Date(day).getMonth() === month)}
calendarDays={calendarDays}
year={this.state.year}
/>
</div>
)
}
The result is a long list of single months:
However, what I want is that once the calendar component is rendered it should scroll to the current month (otherwise users have to scroll down manually to the current month).
I know about refs in React but I'm no sure how to apply this here. Is there a way to scroll to, let's say, e. g. the key of each rendered Month
component?