Skip to content

Enable specific days #1584

Answered by gpbl
DeividZavala asked this question in Support
Oct 12, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

@DeividZavala you can pass the array directly to disabled:

<DayPicker disabled={dates} />

https://codesandbox.io/s/dark-cdn-8w1w4q?file=/src/App.js

Anyway, your diff based on toLocaleString doesn't work – use isSameDay from date-ins:

import { isSameDay } from "date-fns";

export default function App() {
  const dates = ["2022-11-05T06:00:00.000Z", "2022-11-06T06:00:00.000Z"];
  return (
    <DayPicker
      disabled={(date) => dates.some((d) => isSameDay(d, date))}
    />
  );
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DeividZavala
Comment options

Answer selected by DeividZavala
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants