disable days of the week with react-datepicker

Viewed 24

I only want to disable the days of the week that I choose, or otherwise enable the days that I need

here is an illustrative image

here is an illustrative image

I found this code in the documentation but it doesn't work for me

    () => {
  const [startDate, setStartDate] = useState(null);
  const isWeekday = (date) => {
    const day = getDay(date);
    return day !== 0 && day !== 6;
  };
  return (
    <DatePicker
      selected={startDate}
      onChange={(date) => setStartDate(date)}
      filterDate={isWeekday}
      placeholderText="Select a weekday"
    />
  );
};
0 Answers
Related