Some problem about setSelectedDate() and updateWeekView()
See original GitHub issueHello I’m a rookie in react native, I tried to use the TouchableOpacity to navigate to Calendar List.js in calendarStrip.js:
<TouchableOpacity onPress={()=>{navigation.navigate('Calendar List',{onGoBack: this.returnData,})}} style={styles.button1Style}> <Text></Text> </TouchableOpacity>
It will navigate to CalendarList.js and then i wish to select the date to change the calendar strip
CalendarList.js:
onDayPress={(months) => { const selectedDate = months.dateString; this.props.route.params.onGoBack(selectedDate); this.props.navigation.navigate('calendarStrip'); }}
it is able to pass the date back to calendarStrip.js:
returnData=(date)=>{ //console.log('back: ',date) this.calendarRef.updateWeekView(date); this.calendarRef.setSelectedDate(date); }
However there is a problem:
I open the calendar List and selected June 3th, but the week view in calendar strip didn’t change before I press right icon and press left icon back, I’m wondering what happen@@?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top GitHub Comments
I finally solved it! I followed your instruction and fixed my code like this: https://snack.expo.io/@jessehsiao/react-calendar
Thanks for your advice, I will keep working hard!
Glad that you got it working. You should be able to remove the imperative calls to
updateWeekView
andsetSelectedDate
by also setting thestartingDate
prop to the same date asselectedDate
state.