-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalender.js
More file actions
35 lines (30 loc) · 1.04 KB
/
Calender.js
File metadata and controls
35 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React, { useState } from 'react'
import moment from 'moment' // 2.20.1
import { View } from 'react-native' // 0.0.1
import { Calendar } from 'react-native-calendars'
const _format = 'YYYY-MM-DD'
const _today = moment().format(_format)
const _maxDate = moment().add(100, 'days').format(_format)
const WixCalendar = () => {
const [_markedDates, setMarkedDates] = useState([_today])
const onDaySelect = (day) => {
const _selectedDay = moment(day.dateString).format(_format);
let selected = true;
if (_markedDates[_selectedDay]) {
selected = !_markedDates[_selectedDay].selected;
}
const updatedMarkedDates = {..._markedDates, ...{ [_selectedDay]: { selected } } }
setMarkedDates({ _markedDates: updatedMarkedDates });
}
return (
<View style={{flex: 1, marginTop:100}}>
<Calendar
minDate={_today}
maxDate={_maxDate}
onDayPress={onDaySelect}
markedDates={_markedDates}
/>
</View>
);
}
export default WixCalendar