Created
June 11, 2021 02:27
-
-
Save gitumarkk/5f1a47e4cbbf9a6dd44d5b773a117124 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
import dayjs from 'dayjs'; | |
import Calendar from 'react-calendar'; | |
import 'react-calendar/dist/Calendar.css'; | |
/** | |
* MyCalendar allows the user to select a date | |
*/ | |
const MyCalendar = ({id, setProps, date}) => { | |
return ( | |
<div id={id}> | |
<Calendar | |
onChange={(date) => | |
setProps({date: dayjs(date).format('DD-MMM-YYYY')}) | |
} | |
value={dayjs(date, 'DD-MMM-YYYY').toDate()} | |
/> | |
</div> | |
); | |
}; | |
MyCalendar.propTypes = { | |
/** | |
* The ID used to identify this component in Dash callbacks. | |
*/ | |
id: PropTypes.string, | |
/** | |
* The date as a string | |
*/ | |
date: PropTypes.string, | |
/** | |
* Dash-assigned callback that should be called to report property changes | |
* to Dash, to make them available for callbacks. | |
*/ | |
setProps: PropTypes.func, | |
}; | |
export default MyCalendar; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment