question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some problem about setSelectedDate() and updateWeekView()

See original GitHub issue

Hello 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:

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:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jessehsiaocommented, May 29, 2020

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!

0reactions
peacechencommented, May 29, 2020

Glad that you got it working. You should be able to remove the imperative calls to updateWeekView and setSelectedDate by also setting the startingDate prop to the same date as selectedDate state.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Selected date not highlighted if CalendarStrip ... - GitHub
I re-reviewed the code and the changes I posted above aren't necessary. setSelectedDate should do the job. Set a breakpoint in setSelectedDate ......
Read more >
react-native-calendar-strip - npm
getSelectedDate(), Returns the currently selected date. ... setSelectedDate(date), Sets the selected date. date may be a Moment object, ...
Read more >
react-native-calendar-strip/README.md - UNPKG
The Chrome debugger can cause issues with this updating due to a [RN setTimeout ... 151, end: moment().add(3, 'days') // total 4 days...
Read more >
react-native-calendar-strip - Bountysource
I'm currently fetching new calendar dates for markedDates when onWeekChanged is triggered. If the component has a selectedDate, it thinks the selectedDate ...
Read more >
react-native-calendar-strip-fixed - npm package - Snyk
Easy to use and visually stunning calendar component for React Native, forked version for a fix For more information about how to use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found