React-calendar: Unable to clear selected range

Created on 25 Nov 2019  路  2Comments  路  Source: wojtekmaj/react-calendar

It is not possible to clear the selected range, or am I missing something?

dateRangeSelected = selectedDateRange => {
    this.setState({ selectedDateRange: null });
}

<Calendar
    onChange={this.dateRangeSelected}
    value={this.state.selectedDateRange}
    selectRange={true}
/>

This doesn't clear the selection

question

Most helpful comment

I have the same issue - I have the calendar with no initial selection (the 'Custom period' in the gif), but once I start interacting with it the value can never be reset to null. I'm using [email protected].

My simplified code looks similar to the above:

<FilterButton onClick={() => setDateRange(null)}>
  Custom period
</FilterButton>
<Calendar
  value={dateRange}
  onChange={value => setDateRange(value)}
  selectRange
  doubleView
/>

range-reset

All 2 comments

Hi,
have you tried using React-Calendar 3.0 beta as a controlled component? It should have this issue resolved.

I have the same issue - I have the calendar with no initial selection (the 'Custom period' in the gif), but once I start interacting with it the value can never be reset to null. I'm using [email protected].

My simplified code looks similar to the above:

<FilterButton onClick={() => setDateRange(null)}>
  Custom period
</FilterButton>
<Calendar
  value={dateRange}
  onChange={value => setDateRange(value)}
  selectRange
  doubleView
/>

range-reset

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spoldman picture spoldman  路  4Comments

wojtekmaj picture wojtekmaj  路  5Comments

andymj picture andymj  路  5Comments

fasmart4 picture fasmart4  路  6Comments

mikeyharris89 picture mikeyharris89  路  4Comments