Comments (5)
Please try this:
selecionarData = (day) => {
const {datesMarked} = this.state;
datesMarked = {...datesMarked, [day.dateString]: [{startingDay: true, color: '#42aaf4', selected: true}, {selected: true, endingDay: true, color: '#42aaf4', textColor: 'white'}]};
this.setState({datesMarked: datesMarked})
}
Make sure that datesMarkes is not being mutated, but treated as immutable variable (so on each change it is being initialized again)
from react-native-calendars.
Hi, can you paste code of onDayPress
?
from react-native-calendars.
onDayPress(day) { this.props.selecionarData(day); }
selecionarData = (day) => {
const {datesMarked} = this.state;
datesMarked[day.dateString]= [{startingDay: true, color: '#42aaf4', selected: true}, {selected: true, endingDay: true, color: '#42aaf4', textColor: 'white'}];
this.setState({datesMarked: datesMarked})
}
from react-native-calendars.
thanks !
from react-native-calendars.
Hi, I'm encountering the exact same problem. The background color for the dates is not changing unless I press the left or right arrow key to change month.
<Calendar
style={{marginTop: 70}}
minDate={getDate()}
maxDate={getDate('max')}
hideExtraDays={true}
onDayPress={(day)=>{this.selectDate(day)}}
markedDates={this.state.selectedDates}
onMonthChange={(month)=>{this.nextMonth(month);}}
/>
selectDate = (day) => {
const {tappedDates} = this.state;
let updatedTappedDates = {...tappedDates};
if(updatedTappedDates[day.dateString] && updatedTappedDates[day.dateString] < 2){
updatedTappedDates[day.dateString] += 1;
}
else if(updatedTappedDates[day.dateString] === 2){
updatedTappedDates[day.dateString] = 0;
}
else{
updatedTappedDates[day.dateString] = 1;
}
let color;
const calGreen = "#BFE9E6";
const calYellow = "#FBDC98";
const calRed = "#E7808D";
switch (updatedTappedDates[day.dateString]) {
case 0:
color = calGreen;
break;
case 1:
color = calYellow;
break;
case 2:
color = calRed;
break;
default:
color = calGreen;
}
// const {selectedDates} = this.state;
// selectedDates = {...selectedDates, [day.dateString]: {selected: true, selectedColor: 'orange'}};
-------if i write these two lines above, based on the solution you provided to vagnerSI, I get an
error saying "selectedDates is read-only"-------
// const {selectedDates} = this.state;
// let newSelectedDates = {...selectedDates, [day.dateString]: {selected: true, selectedColor:
color}};
---- I tried this solution as well but not successful-------
let selectedDates = Object.assign({}, this.state.selectedDates);
selectedDates[day.dateString] = {selected: true, selectedColor: color};
this.setState({selectedDates: selectedDates});
------ I tried this solution as well after looking at some of your answers to other people having the
same problem, but this one is not successful either ----
};
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.