Describe the bug
onSelectedChange is being called multiple times on selecting a date its hard to add any side effect behaviour. Even if date is already selected then also on selected change is being called.
To Reproduce
Steps to reproduce the behavior:
import moment from 'moment'
import React, { useState } from 'react'
import DatePicker from 'react-native-modern-datepicker'
Describe the bug onSelectedChange is being called multiple times on selecting a date its hard to add any side effect behaviour. Even if date is already selected then also on selected change is being called.
To Reproduce Steps to reproduce the behavior: import moment from 'moment' import React, { useState } from 'react' import DatePicker from 'react-native-modern-datepicker'
export const CalendarModal = ({ isVisible, closeModal, onDayPress }) => { const firstTime = React.useRef(0) const handleConfirm = (date) => { console.log('date', date, firstTime.current)
}
React.useEffect(() => { if (isVisible) { firstTime.current = true } }, [isVisible])
const [selectedDate, setSelectedDate] = useState('')
console.log(selectedDate) return ( <DatePicker // current={selectedDate} selected={selectedDate} onSelectedChange={(date) => { handleConfirm(date) }} options={{ mainColor: '#30B700' }} mode="calendar" minuteInterval={30} style={{ borderRadius: 10 }} /> ) }
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context Add any other context about the problem here.