-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to update markedDates from onDayPress event #283
Comments
You can track the marked dates as state in a stateful React component, here's an example I've based of your expo example:
|
Thank you @eddiegroves! It's almost that I make here. |
Not sure I follow, the example above should be re-rendering and showing the updated marked day automatically. Here's a tweaked example where the dotColor theme is set https://snack.expo.io/r1bMAvN7z |
@eddiegroves Thank you for your help from the beginning. Well.. I'll from your first example and tell you how it went. EDIT: It works for me!! Aleluia!! 🥇 Thank you for |
@francisrod01 If you're new to React it will take a while for it to 'click' but keep at it and things like this will be easier! 👍 |
@eddiegroves What we do it better using the new lifecycle's React?
|
my version without moment, and I had to change two lines to get it to work (on and off):
and
all code:
|
see my stackoverflow answer for how to make them select and deselect: https://stackoverflow.com/questions/52448375/react-native-rerender-child-component-from-parent-component/52451333#52451333 |
Does anyone get perf issue while |
Thx so much!!! |
yes! how did you handle that? |
Description
So... how to toggle (mark/unmark) dates when
onDayPress
was called?Some like this:
Expected Behavior
I tried to do this with Object.keys(), push and splice but
markedDates
haven't a index to manipulate it, so it's very difficult to me to do this.Observed Behavior
Date marking
!Disclaimer! Make sure that markedDates param is immutable. If you change markedDates object content but the reference to it does not change calendar update will not be triggered.
Environment
yarn info react-native-calendars
:{latest: '1.16.1'}
yarn info react-native
:{latest: '0.51.0'}
Genymotion 2.11.0
Reproducible Demo
codepen demo
expo demo
The same code can to see below:
some imports:
defining constants:
onDayPress method called:
and the calendar component below:
EDIT:
I've been working to improved this with clean JS:
https://codepen.io/francisrod01/pen/RxKQeO
I clicked in day 31 but the day doesn't marked in the calendar.
The text was updated successfully, but these errors were encountered: