Closed sparshag007 closed 3 years ago
The onDateSelected
callback is intended to fire when the user selects a date. It specifically does not fire when the selectedDate
prop changes because that can easily lead to infinite loops: selectedDate change -> onDateSelected fires and sets selectedDate state -> selectedDate change...
That scenario can happen even if the date value is the same but its underlying object changes (e.g. a date clone).
As the consumer of this library, you know exactly when you change selectedDate's value. Your code should detect that and take the appropriate action.
selectedDate prop lets you select the default date when the calendar-strip is rendered. eg:
selectedDate={moment()}
selects the current date by default.onDateSelected prop lets you execute a function or define a behavior as to what should happen when user selects a date eg:
onDateSelected={(selectedDate)=>{ alert('Hello People')} }
displays an alert when date is selectedThe problem lies here is when the component is rendered , the selectedDate should also display an alert as it should execute the same behavior as onSelectedDate
Is there a way to do it?