Reputation: 33
am using react-native-calendar-picker library.trying to get the selected date but i receive previews date.
onDateChange (date) {
this.setState({ date: date });
}
<CalendarPicker selectedDate={this.state.date}
onDateChange=(date)=>this.onDateChange(date)}}/>
Upvotes: 1
Views: 2763
Reputation: 3550
I would recommend to use react-native-calendar
You can get it from here : https://github.com/christopherdro/react-native-calendar
Usage Example :
<Calendar
scrollEnabled={true}
showControls={true}
titleFormat={'MMMM YYYY'}
dayHeadings={['Sun', 'Mon', 'Tue', 'Wed', 'Thu','Fri','Sat']}
monthNames={['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec']}
prevButtonText={'Prev'}
nextButtonText={'Next'}
onDateSelect={(date) => this.onDateChange(date)}
onTouchPrev={this.onTouchPrev}
onTouchNext={this.onTouchNext}
onSwipePrev={this.onSwipePrev}
onSwipeNext={this.onSwipeNext}
eventDates={this.state.events}
customStyle={{day: {fontSize: 15, textAlign: 'center', color: '#4c4b4b'}}}
weekStart={1}
/>
Upvotes: 1