stephy / CalendarPicker

CalendarPicker Component for React Native
803 stars 373 forks source link

initialDate not working #215

Closed maniac-tech closed 4 years ago

maniac-tech commented 4 years ago

The initialDate prop of the CalendarComponent isn't populating the initial date being passed.

My Code snippet: <CalendarComponent initialDate={new Date(2020, 6, 13)} dateChanged={this.dateChanged}/>

peacechen commented 4 years ago

initialDate sets the month that the calendar opens to. selectedStartDate is the prop that marks a date as selected.

The prop dateChanged in your code snippet isn't supported. You may have meant to use onDateChange.

maniac-tech commented 4 years ago

selectedStartDate

My intention here is to load the Calendar component with a provided date.

As per what you pointed, is this the right approach: <CalendarComponent selectedStartDate={initalDate} onDateChange={this.dateChanged}/> ?

maniac-tech commented 4 years ago

@peacechen The issue hasn't been resolved yet, your suggested way isn't working as expected.

Can you attach a small Code snippet?

peacechen commented 4 years ago

Could you clarify your requirements? If it's difficult to describe, an image mockup may help.

maniac-tech commented 4 years ago

Could you clarify your requirements? If it's difficult to describe, an image mockup may help.

I want the Calendar to open with a default date of Today

peacechen commented 4 years ago

Your code snippet should work:

<CalendarPicker
  selectedStartDate={moment()}
  onDateChange={this.dateChanged}
/>

The default month that it opens to is the initialDate prop, which is "today". selectedStartDate marks the date as selected.