Skip to content

How to display selected day/dates (when DateRangePicker)? #579

Answered by wojtekmaj
filippos13 asked this question in Q&A
Discussion options

You must be logged in to vote

Since depending on the configuration React-Calendar may return a date or an array of dates, here's what I'm using in test suite to render currently selected dates:

function renderDebugInfo() {
const renderDate = (dateToRender) => {
if (dateToRender instanceof Date) {
return formatDate(locale, dateToRender);
}
return dateToRender;
};
if (Array.isArray(value)) {
return (
<p>
{`Chosen date range: ${renderDate(value[0])} - ${renderDate(value[1])}`}
</p>
);
}
return (
<p>
{`Chosen date: ${value ? renderDate(value) : '(none)'}`}
</p>

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@filippos13
Comment options

@wojtekmaj
Comment options

Answer selected by wojtekmaj
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants