Enable specific days #1584
-
Hello, I need help to solve this problem. I am trying to limit the dates that can be selected by a matcher in the My logic is as follows: disabled={date => {
// I'm using toLocaleString method to ensure that I'm comparing the same thing
return dates.some((d) => new Date(d).toLocaleString() !== date.toLocaleString())
}} The result of this is that the component disabled everything, including the dates on the array. I tried changing the operator to the Any suggestion? Thanks for the help EXAMPLE: https://codesandbox.io/s/vigorous-julien-7fr3zf?file=/src/App.js |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@DeividZavala you can pass the array directly to <DayPicker disabled={dates} /> https://codesandbox.io/s/dark-cdn-8w1w4q?file=/src/App.js Anyway, your diff based on 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))}
/>
);
} |
Beta Was this translation helpful? Give feedback.
@DeividZavala you can pass the array directly to
disabled
:https://codesandbox.io/s/dark-cdn-8w1w4q?file=/src/App.js
Anyway, your diff based on
toLocaleString
doesn't work – useisSameDay
from date-ins: