简体   繁体   中英

How to get the selected dates? in react calendar

I downloaded react-native-material-calandarview inside my project.

They just give some piece of code to get calendar. https://github.com/NuclleaR/react-native-material-calendarview .

I used that inside my render(). selectedDates={this.state.dates}......{this.state.dates} it gives undefined. I need the selected dates array,but i cant get that. where i get the selected dates??? Help me ASAP.Thanks in advance

The calendar expose you an event function onDateChange , you have just to setState in this event like that:

<Calendar
  selectedDates={this.state.dates}
  onDateChange={data => {
    // Add the data to your state here
    // for example:
    this.setState(state => { dates: state.dates.push(data.date) });
  }}
/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM