Comments (12)
@chapeljuice this is a basic version of what I used.
<Calendar firstDay={1} onDayPress={this.onSelectDay} markedDates={this.dates} markingType="interactive" minDate={today} hideExtraDays={true} />
This is the onSelectDay function
`const { booked, dates } = this.state
const selectedDate = date.dateString
if ( dates[selectedDate] ) {
const newDates = { ...dates }
delete newDates[selectedDate]
this.setState( {
dates: newDates
} )
} else {
const newDates = { ...dates }
newDates[selectedDate] = [
{startingDay: true, color: colors.sea, textColor: colors.white},
{endingDay: true, color: colors.sea, textColor: colors.white},
]
this.setState( {
dates: newDates
} )
}`
from react-native-calendars.
It should be working, I suspect there is a bug in componentShouldUpdate and rerender does not happen. I will look into it.
from react-native-calendars.
Yes dude that's perfect now!! cheers mate :)
from react-native-calendars.
Sorry to bring this up but I'm trying to implement this functionality but I'm a bit stumped as to how. Could either of you @tautvilas @davidfloegel help out?
Thanks
(Let me know if this needs to be a separate issue)
from react-native-calendars.
Awesome thank you :)
from react-native-calendars.
Do you mutate this.state.marked
in onDayPress
? I think the API is built on the premise that immutable objects are being passed to it (so that reference checks can be done in shouldComponentUpdate
). What if you recreate the this.state.marked
object on each selection? Maybe it solves the problem?
from react-native-calendars.
from react-native-calendars.
could you post onSelect
code?
from react-native-calendars.
Sorry for the delay!
Sorry for the messy code, it's just for trying out:
onSelect( date ) {
const { marked } = this.state
let { year, month, day } = date
month = month < 10 ? `0${ month }` : month
day = day < 10 ? `0${ day }` : day
const key = `${ year }-${ month }-${ day }`
const index = marked.indexOf( key )
if( index > -1 ) {
this.setState( { marked: [
...marked.slice( 0, index ),
...marked.slice( index + 1 )
] } )
} else {
this.setState( { marked: [
...marked,
key
] } )
}
}
I even tried to do a deep clone when passing in the dates into the calendar but no luck!
from react-native-calendars.
Hey, I changed marking api in new version to be easier to use. Now you can specified if date is selected or marked in same markedDates
object
https://github.com/wix/react-native-calendars/blob/master/README.md#date-marking
Also added dateString
prop to object returned from onDayPress
so you don't need to do manual conversion anymore.
Plz check if these changes solve your bug
from react-native-calendars.
I would also like to know how to do this if you have a minute to spare for some code examples! Lovely calendar, btw!
from react-native-calendars.
Hi @tautvilas ,
im trying to highlight days for whole years.But i can only highlight days for current month.How to highlight days for all months using onMonthChange().
from react-native-calendars.
Related Issues (20)
- Make AgendaList scroll to today by default HOT 3
- There is a way to handle with week change in <weekCalendar /> HOT 1
- Types are wrong with AgendaSchedule hardcoded
- Webpack loader errors in solito nextjs app HOT 1
- React Native Calendars height is fixed by default
- React Native Calendars height is fixed by default cannot be changed why?Is there any way to decrease the height of calendar? HOT 1
- Add StandWithPalentine banner
- How will manually pick a date to start from ? HOT 1
- setNativeProps is not a function when pressing the knob of Agenda (tested with chrome)
- Asking a question regarding day header styling HOT 1
- ExpandableCalendar
- Performance : limit rerender of calendar
- March 31 missing in Calendar
- Expandable calendar height issue: Last week of month is not shown with customized design HOT 4
- Invariant Violation: requireNativeComponent: "RNSVGSvgView" was not found in the UIManager got this issue every time when trying to install react-native-calender
- Create Event similar to IOS calendars with Timeline compoenent, on LongPress where backgorundColor changes and reflects selectedTime of 1h?
- Facing date selection change issue on Expandable calendar week change
- im facing issue while long pressing on timeline im getting a day befores date,as an event
- Expandable calendar always shows the first day auto selected HOT 8
- How to get Data inside AgendaList
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-calendars.