React-datepicker: Filter dates

Created on 26 Apr 2017  路  7Comments  路  Source: Hacker0x01/react-datepicker

Following example code for Filter dates to only display weekdays produces different results than example page.

<DatePicker
  selected={ this.state.startDate }
  onChange={ this.handleChange }
  filterDate={this.isWeekday}
  placeholderText="Select a weekday"
/>

Desired behavior:
screenshot3

Current behavior:
screenshot2

Most helpful comment

It would be great if these were in the docs. It just asks for a function without any info on the function.

All 7 comments

@vmiimu Did you provide the isWeekday function in your component?

isWeekday = (date) => {
    const day = date.day()
    return day !== 0 && day !== 6
  }

Closing due inactivity.

It would be great if these were in the docs. It just asks for a function without any info on the function.

@jamparke, contributions to improve the docs are welcome

If others end up here, this is now:
```javascript
const isWeekday = (date) => {
const day = date.getDay()
return day !== 0 && day !== 6
}

@vmiimu Did you provide the isWeekday function in your component?

isWeekday = (date) => {
    const day = date.day()
    return day !== 0 && day !== 6
  }

Hi Mgrdevport
date.day() is working in your side?

@vmiimu Did you provide the isWeekday function in your component?

isWeekday = (date) => {
    const day = date.day()
    return day !== 0 && day !== 6
  }

Hi Mgrdevport
date.day() is working in your side?

try this

isWeekday = date => {
  const day = getDay(date)
  return day !== 0 && day !== 6
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

lclemence picture lclemence  路  3Comments

pinturic picture pinturic  路  3Comments

jjjss94 picture jjjss94  路  3Comments

ali-master picture ali-master  路  3Comments

arturictus picture arturictus  路  3Comments